commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1125745 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Date Sat, 21 May 2011 16:58:55 GMT
Author: markt
Date: Sat May 21 16:58:55 2011
New Revision: 1125745

URL: http://svn.apache.org/viewvc?rev=1125745&view=rev
Log:
Don't decrement itemsToRemove when attempting to clear a non-idle object.

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

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1125745&r1=1125744&r2=1125745&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Sat May 21 16:58:55 2011
@@ -1417,12 +1417,16 @@ public class GenericKeyedObjectPool<K,T>
              // list it belongs to.
              K key = entry.getValue();
              PooledObject<T> p = entry.getKey();
+             // Assume the destruction succeeds
+             boolean destroyed = true;
              try {
-                destroy(key, p, false);
+                 destroyed = destroy(key, p, false);
             } catch (Exception e) {
                 // TODO - Ignore?
             }
-            itemsToRemove--;
+            if (destroyed) {
+                itemsToRemove--;
+            }
         }
     }
 
@@ -1586,7 +1590,7 @@ public class GenericKeyedObjectPool<K,T>
         return p;
     }
 
-    private void destroy(K key, PooledObject<T> toDestory, boolean always)
+    private boolean destroy(K key, PooledObject<T> toDestory, boolean always)
             throws Exception {
         
         register(key);
@@ -1604,6 +1608,9 @@ public class GenericKeyedObjectPool<K,T>
                     objectDeque.getCreateCount().decrementAndGet();
                     numTotal.decrementAndGet();
                 }
+                return true;
+            } else {
+                return false;
             }
         } finally {
             deregister(key);



Mime
View raw message