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/05/25 10:56:22 UTC
svn commit: r778357 - in /commons/proper/pool/trunk/src:
java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
java/org/apache/commons/pool/impl/GenericObjectPool.java
test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Author: markt
Date: Mon May 25 08:56:21 2009
New Revision: 778357
URL: http://svn.apache.org/viewvc?rev=778357&view=rev
Log:
Add Phil's test case for WHEN_EXHAUSTED_GROW and fix the bug it identified.
When growing the pool, still need to remove the latch from the allocation queue and increment the internal processing count.
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
commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.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=778357&r1=778356&r2=778357&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 Mon May 25 08:56:21 2009
@@ -1104,7 +1104,11 @@
// the pool is exhausted
switch(whenExhaustedAction) {
case WHEN_EXHAUSTED_GROW:
- // allow new object to be created
+ // allow new object to be created
+ synchronized (this) {
+ _allocationQueue.remove(latch);
+ latch.getPool().incrementInternalProcessingCount();
+ }
break;
case WHEN_EXHAUSTED_FAIL:
synchronized (this) {
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=778357&r1=778356&r2=778357&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 Mon May 25 08:56:21 2009
@@ -969,6 +969,10 @@
switch(whenExhaustedAction) {
case WHEN_EXHAUSTED_GROW:
// allow new object to be created
+ synchronized (this) {
+ _allocationQueue.remove(latch);
+ _numInternalProcessing++;
+ }
break;
case WHEN_EXHAUSTED_FAIL:
synchronized (this) {
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java?rev=778357&r1=778356&r2=778357&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java Mon May 25 08:56:21 2009
@@ -1458,6 +1458,14 @@
return false;
}
+ public void testWhenExhaustedGrow() throws Exception {
+ pool.setMaxActive(1);
+ pool.setMaxTotal(1);
+ pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
+ for (int i = 0; i < 10; i++) {
+ pool.borrowObject("a");
+ }
+ }
}