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

GenericObjectPool.returnObject() is NOT throwing IllegalStateException for object has already been returned

    XMLWordPrintableJSON

    Details

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

      Description

      When GenericObjectPool is created using AbandonedConfig, the pool is NOT throwing "IllegalStateException: Object has already been returned to this pool or is invalid" for object has already been returned.

      final GenericObjectPool<String> pool = new GenericObjectPool<String>(
      new SimpleFactory(), new GenericObjectPoolConfig(),
      new AbandonedConfig());

      String obj1 = pool.borrowObject();
      System.out.println("after borrowing obj1");
      System.out.println("numActive=" + pool.getNumActive());
      System.out.println("numIdle=" + pool.getNumIdle());

      System.out.println("return obj1");
      pool.returnObject(obj1);
      System.out.println("numActive=" + pool.getNumActive());
      System.out.println("numIdle=" + pool.getNumIdle());

      System.out.println("return obj1 again");
      pool.returnObject(obj1);
      System.out.println("numActive=" + pool.getNumActive());
      System.out.println("numIdle=" + pool.getNumIdle());

      Output:
      after borrowing obj1
      numActive=1
      numIdle=0
      return obj1
      numActive=0
      numIdle=1
      return obj1 again
      numActive=-1
      numIdle=2

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chen168 Warren Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: