Uploaded image for project: 'Commons Pool'
  1. Commons Pool
  2. POOL-207

GenericKeyedObjectPool.clear() has unnecessary null check of objectDequeue

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Labels:
      None

      Description

      GenericKeyedObjectPool.clear() registers the key, and then checks if the objectDeque obtained by using the key is null.

      Since register creates the key entry in poolMap, the retrieved value should never be null.
      If it is nullm then AFAICT that is a code bug, which should be reported rather than ignored.

      [If it were possible for the key to be null, then the same null check should be added to the private destroy method.]

      Also, register returns the ObjectDeque, so the clear() code could be simplified; rather than

      register(key);
      
      try {
          ObjectDeque<T> objectDeque = poolMap.get(key);
          if (objectDeque == null) {
              return;
          }
          ...
      

      the method could use:

      ObjectDeque<T> objectDeque = register(key);
      
      try {
          ...
      

      Similarly for the private destroy method.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: