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 2009/06/13 19:42:29 UTC
svn commit: r784441 - in
/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl:
GenericKeyedObjectPool.java GenericObjectPool.java
Author: markt
Date: Sat Jun 13 17:42:28 2009
New Revision: 784441
URL: http://svn.apache.org/viewvc?rev=784441&view=rev
Log:
Fix POOL-144 and related issues for GOP and GKOP.
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=784441&r1=784440&r2=784441&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java Sat Jun 13 17:42:28 2009
@@ -1106,12 +1106,21 @@
case WHEN_EXHAUSTED_GROW:
// allow new object to be created
synchronized (this) {
- _allocationQueue.remove(latch);
- latch.getPool().incrementInternalProcessingCount();
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() == null) {
+ _allocationQueue.remove(latch);
+ latch.getPool().incrementInternalProcessingCount();
+ }
}
break;
case WHEN_EXHAUSTED_FAIL:
synchronized (this) {
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() != null) {
+ break;
+ }
_allocationQueue.remove(latch);
}
throw new NoSuchElementException("Pool exhausted");
@@ -1136,6 +1145,15 @@
throw e;
}
if (maxWait > 0 && ((System.currentTimeMillis() - starttime) >= maxWait)) {
+ synchronized (this) {
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() == null) {
+ _allocationQueue.remove(latch);
+ } else {
+ break;
+ }
+ }
throw new NoSuchElementException("Timeout waiting for idle object");
} else {
continue; // keep looping
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=784441&r1=784440&r2=784441&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Sat Jun 13 17:42:28 2009
@@ -1074,12 +1074,21 @@
case WHEN_EXHAUSTED_GROW:
// allow new object to be created
synchronized (this) {
- _allocationQueue.remove(latch);
- _numInternalProcessing++;
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() == null) {
+ _allocationQueue.remove(latch);
+ _numInternalProcessing++;
+ }
}
break;
case WHEN_EXHAUSTED_FAIL:
synchronized (this) {
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() != null) {
+ break;
+ }
_allocationQueue.remove(latch);
}
throw new NoSuchElementException("Pool exhausted");
@@ -1104,6 +1113,16 @@
throw e;
}
if(maxWait > 0 && ((System.currentTimeMillis() - starttime) >= maxWait)) {
+ synchronized(this) {
+ // Make sure allocate hasn't already assigned an object
+ // in a different thread
+ if (latch.getPair() == null) {
+ // Remove latch from the allocation queue
+ _allocationQueue.remove(latch);
+ } else {
+ break;
+ }
+ }
throw new NoSuchElementException("Timeout waiting for idle object");
} else {
continue; // keep looping