commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1205266 - in /commons/proper/pool/branches/POOL_1_X/src: changes/changes.xml java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Date Wed, 23 Nov 2011 02:09:07 GMT
Author: psteitz
Date: Wed Nov 23 02:09:06 2011
New Revision: 1205266

URL: http://svn.apache.org/viewvc?rev=1205266&view=rev
Log:
Corrected total internal processing counter update in destroy.  Prior to the fix
for this issue, clear(key) was leaking capacity associated with elements in the
pool being cleared.

JIRA: POOL-192
Reported and patched by Helge Dannenberg


Modified:
    commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml
    commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java

Modified: commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml?rev=1205266&r1=1205265&r2=1205266&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml (original)
+++ commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml Wed Nov 23 02:09:06 2011
@@ -26,6 +26,11 @@
       IllegalStateException.  Prior to the fix for this issue, threads waiting in borrowObject
when
       close was invoked on GOP or GKOP would block indefinitely.
     </action>
+    <action dev="psteitz" type="fix" issue="POOL-192" due-to="Helge Dannenberg">
+      Corrected total internal processing counter update in destroy.  Prior to the fix
+      for this issue, clear(key) was leaking capacity associated with elements in the
+      pool being cleared.
+    </action>
   <release version="1.5.6" date="2011-04-03" description="This is a patch release, including
bugfixes only.">
     <action dev="markt" type="fix" issue="POOL-179" due-to="Axel Grossmann">
       Correctly handle an InterruptedException when waiting for an object from

Modified: commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1205266&r1=1205265&r2=1205266&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Wed Nov 23 02:09:06 2011
@@ -1501,6 +1501,8 @@ public class GenericKeyedObjectPool exte
                                 _poolMap.remove(key);
                                 _poolList.remove(key);
                             }
+                        } else {
+                            _totalInternalProcessing--;
                         }
                     }
                     allocate();

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java?rev=1205266&r1=1205265&r2=1205266&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Wed Nov 23 02:09:06 2011
@@ -1450,6 +1450,35 @@ public class TestGenericKeyedObjectPool 
         runTestThreads(20, 300, 250);
     }
     
+    /**
+     * POOL-192
+     * Verify that clear(key) does not leak capacity due to _numInternalProcessing
+     * not being decremented.
+     */
+    public void testClear() throws Exception {
+        SimpleFactory factory = new SimpleFactory();
+        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        pool.setMaxTotal(2);
+        pool.setMaxActive(2);
+        pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
+        pool.addObject("one");
+        pool.addObject("one");
+        assertEquals(2, pool.getNumIdle());
+        pool.clear("one");
+        assertEquals(0, pool.getNumIdle());
+        assertEquals(0, pool.getNumIdle("one"));
+        Object obj1 = pool.borrowObject("one");
+        Object obj2 = pool.borrowObject("one");
+        pool.returnObject("one", obj1);
+        pool.returnObject("one", obj2);
+        pool.clear();
+        assertEquals(0, pool.getNumIdle());
+        assertEquals(0, pool.getNumIdle("one"));
+        pool.borrowObject("one");
+        pool.borrowObject("one");
+        pool.close();
+    }
+    
     /*
      * Very simple test thread that just tries to borrow an object from
      * the provided pool with the specified key and returns it



Mime
View raw message