You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2011/06/08 16:47:45 UTC
svn commit: r1133416 - in /commons/proper/pool/trunk/src: changes/changes.xml
java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
java/org/apache/commons/pool2/impl/GenericObjectPool.java
Author: markt
Date: Wed Jun 8 14:47:45 2011
New Revision: 1133416
URL: http://svn.apache.org/viewvc?rev=1133416&view=rev
Log:
Guard against the same object being returned to a pool multiple times.
Modified:
commons/proper/pool/trunk/src/changes/changes.xml
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
Modified: commons/proper/pool/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/changes/changes.xml?rev=1133416&r1=1133415&r2=1133416&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Wed Jun 8 14:47:45 2011
@@ -51,6 +51,9 @@
<action dev="markt" type="fix" issue="POOL-188" due-to="sebb">
Remove confusing method PoolUtils.ErodingKeyedObjectPool.numIdle(K key).
</action>
+ <action dev="markt" type="update">
+ Guard against multiple returns of the same object to the pool.
+ </action>
</release>
<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">
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=1133416&r1=1133415&r2=1133416&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 Wed Jun 8 14:47:45 2011
@@ -825,7 +825,8 @@ public class GenericKeyedObjectPool<K,T>
}
if (!p.deallocate()) {
- // TODO - Should not happen;
+ throw new IllegalStateException(
+ "Object has already been retured to this pool");
}
int maxIdle = getMaxIdlePerKey();
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1133416&r1=1133415&r2=1133416&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java Wed Jun 8 14:47:45 2011
@@ -1328,15 +1328,6 @@ public class GenericObjectPool<T> extend
* instance is validated before being returned to the idle instance pool. In
* this case, if validation fails, the instance is destroyed.
* </p>
- * <p>
- * <strong>Note: </strong> There is no guard to prevent an object being
- * returned to the pool multiple times. Clients are expected to discard
- * references to returned objects and ensure that an object is not returned
- * to the pool multiple times in sequence (i.e., without being borrowed
- * again between returns). Violating this contract will result in the same
- * object appearing multiple times in the pool and pool counters (numActive,
- * numIdle) returning incorrect values.
- * </p>
*
* @param obj
* instance to return to the pool
@@ -1374,7 +1365,8 @@ public class GenericObjectPool<T> extend
}
if (!p.deallocate()) {
- // TODO - Should not happen;
+ throw new IllegalStateException(
+ "Object has already been retured to this pool");
}
int maxIdle = getMaxIdle();