Return-Path:
X-Original-To: apmail-commons-commits-archive@minotaur.apache.org
Delivered-To: apmail-commons-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id E2DB04F84
for ;
Wed, 8 Jun 2011 14:48:09 +0000 (UTC)
Received: (qmail 50594 invoked by uid 500); 8 Jun 2011 14:48:09 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 50537 invoked by uid 500); 8 Jun 2011 14:48:09 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 50530 invoked by uid 99); 8 Jun 2011 14:48:09 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jun 2011 14:48:09 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jun 2011 14:48:07 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 9798823889ED; Wed, 8 Jun 2011 14:47:45 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: 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
Date: Wed, 08 Jun 2011 14:47:45 -0000
To: commits@commons.apache.org
From: markt@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20110608144745.9798823889ED@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
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 @@
Remove confusing method PoolUtils.ErodingKeyedObjectPool.numIdle(K key).
+
+ Guard against multiple returns of the same object to the pool.
+
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
}
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 extend
* instance is validated before being returned to the idle instance pool. In
* this case, if validation fails, the instance is destroyed.
*
- *
- * Note: 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.
- *
*
* @param obj
* instance to return to the pool
@@ -1374,7 +1365,8 @@ public class GenericObjectPool extend
}
if (!p.deallocate()) {
- // TODO - Should not happen;
+ throw new IllegalStateException(
+ "Object has already been retured to this pool");
}
int maxIdle = getMaxIdle();