commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject 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
Date Mon, 25 May 2009 08:56:22 GMT
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");
+        }
+    } 
 }
 
 



Mime
View raw message