You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2013/11/26 17:09:48 UTC

svn commit: r1545705 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Author: psteitz
Date: Tue Nov 26 16:09:48 2013
New Revision: 1545705

URL: http://svn.apache.org/r1545705
Log:
Added calls to addObject(K) to ensure liveness when objects are destroyed on return
or invalidated by clients.

JIRA: POOL-240



Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1545705&r1=1545704&r2=1545705&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Tue Nov 26 16:09:48 2013
@@ -478,6 +478,13 @@ public class GenericKeyedObjectPool<K,T>
                 } catch (Exception e) {
                     swallowException(e);
                 }
+                if (objectDeque.idleObjects.hasTakeWaiters()) {
+                    try {
+                        addObject(key);
+                    } catch (Exception e) {
+                        swallowException(e);
+                    }
+                }
                 updateStatsReturn(activeTime);
                 return;
             }
@@ -492,6 +499,13 @@ public class GenericKeyedObjectPool<K,T>
             } catch (Exception e) {
                 swallowException(e);
             }
+            if (objectDeque.idleObjects.hasTakeWaiters()) {
+                try {
+                    addObject(key);
+                } catch (Exception e) {
+                    swallowException(e);
+                }
+            }
             updateStatsReturn(activeTime);
             return;
         }
@@ -556,6 +570,9 @@ public class GenericKeyedObjectPool<K,T>
                 destroy(key, p, true);
             }
         }
+        if (objectDeque.idleObjects.hasTakeWaiters()) {
+            addObject(key);
+        }
     }
 
 

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1545705&r1=1545704&r2=1545705&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Tue Nov 26 16:09:48 2013
@@ -1781,7 +1781,7 @@ public class TestGenericKeyedObjectPool 
      *
      * JIRA: POOL-240
      */
-    //@Test
+    @Test
     public void testInvalidateWaiting()
         throws Exception {
 
@@ -1860,7 +1860,7 @@ public class TestGenericKeyedObjectPool 
      *
      * JIRA: POOL-240
      */
-    //@Test
+    @Test
     public void testInvalidateFreesCapacity()
         throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();
@@ -1890,7 +1890,7 @@ public class TestGenericKeyedObjectPool 
      *
      * JIRA: POOL-240
      */
-    //@Test
+    @Test
     public void testValidationFailureOnReturnFreesCapacity()
         throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();