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/05/17 22:52:30 UTC

svn commit: r1104552 - in /commons/proper/pool/trunk/src: changes/ java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/impl/

Author: markt
Date: Tue May 17 20:52:29 2011
New Revision: 1104552

URL: http://svn.apache.org/viewvc?rev=1104552&view=rev
Log:
Remove WhenExhuastedAction.GROW. The same can be achieved with FAIL and maxActive==Integer.MAX_VALUE

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
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.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=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Tue May 17 20:52:29 2011
@@ -44,6 +44,10 @@
       Introduce an Enum (WhenExhaustedAction) to control pool behaviour when no
       more objects are available to allocate.
     </action>
+    <action dev="markt" type="update">
+      Remove WhenExhuastedAction.GROW since it is equivalent to
+      WhenExhuastedAction.FAIL with a maxActive value of Integer.MAX_VALUE. 
+    </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=1104552&r1=1104551&r2=1104552&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 Tue May 17 20:52:29 2011
@@ -1040,7 +1040,7 @@ public class GenericKeyedObjectPool<K,T>
                     }
                     if (p == null) {
                         create = true;
-                        p = create(key, false);
+                        p = create(key);
                     }
                     if (p == null) {
                         throw new NoSuchElementException("Pool exhausted");
@@ -1054,7 +1054,7 @@ public class GenericKeyedObjectPool<K,T>
                     }
                     if (p == null) {
                         create = true;
-                        p = create(key, false);
+                        p = create(key);
                     }
                     if (p == null && objectDeque != null) {
                         if (maxWait < 1) {
@@ -1071,17 +1071,6 @@ public class GenericKeyedObjectPool<K,T>
                     if (!p.allocate()) {
                         p = null;
                     }
-                } else if (whenExhaustedAction == WhenExhaustedAction.GROW) {
-                    if (objectDeque != null) {
-                        p = objectDeque.getIdleObjects().pollFirst();
-                    }
-                    if (p == null) {
-                        create = true;
-                        p = create(key, true);
-                    }
-                    if (p != null && !p.allocate()) {
-                        p = null;
-                    }
                 }
     
                 if (p != null) {
@@ -1329,7 +1318,7 @@ public class GenericKeyedObjectPool<K,T>
      public int getNumActive(K key) {
          final ObjectDeque<T> objectDeque = poolMap.get(key);
          if (objectDeque != null) {
-             return objectDeque.getNumActive().get() -
+             return objectDeque.getAllObjects().size() -
                      objectDeque.getIdleObjects().size();
          } else {
              return 0;
@@ -1451,111 +1440,107 @@ public class GenericKeyedObjectPool<K,T>
       *
       * @throws Exception when there is a problem evicting idle objects.
       */
-     public void evict() throws Exception {
-         assertOpen();
+    public void evict() throws Exception {
+        assertOpen();
 
-         if (getNumIdle() == 0) {
-             return;
-         }
+        if (getNumIdle() == 0) {
+            return;
+        }
 
-         boolean testWhileIdle = _testWhileIdle;
-         long idleEvictTime = Long.MAX_VALUE;
+        boolean testWhileIdle = _testWhileIdle;
+        long idleEvictTime = Long.MAX_VALUE;
          
-         if (getMinEvictableIdleTimeMillis() > 0) {
-             idleEvictTime = getMinEvictableIdleTimeMillis();
-         }
+        if (getMinEvictableIdleTimeMillis() > 0) {
+            idleEvictTime = getMinEvictableIdleTimeMillis();
+        }
 
-         PooledObject<T> underTest = null;
-         LinkedBlockingDeque<PooledObject<T>> idleObjects = null;
+        PooledObject<T> underTest = null;
+        LinkedBlockingDeque<PooledObject<T>> idleObjects = null;
          
-         for (int i = 0, m = getNumTests(); i < m; i++) {
-             if(evictionIterator == null || !evictionIterator.hasNext()) {
-                 if (evictionKeyIterator == null ||
-                         !evictionKeyIterator.hasNext()) {
-                     List<K> keyCopy = new ArrayList<K>();
-                     keyCopy.addAll(poolKeyList);
-                     evictionKeyIterator = keyCopy.iterator();
-                 }
-                 while (evictionKeyIterator.hasNext()) {
-                     evictionKey = evictionKeyIterator.next();
-                     ObjectDeque<T> objectDeque = poolMap.get(evictionKey);
-                     if (objectDeque == null) {
-                         continue;
-                     }
-                     idleObjects = objectDeque.getIdleObjects();
-                     
-                     if (getLifo()) {
-                         evictionIterator = idleObjects.descendingIterator();
-                     } else {
-                         evictionIterator = idleObjects.iterator();
-                     }
-                     if (evictionIterator.hasNext()) {
-                         break;
-                     }
-                     evictionIterator = null;
-                 }
-             }
-             if (evictionIterator == null) {
-                 // Pools exhausted
-                 return;
-             }
-             try {
-                 underTest = evictionIterator.next();
-             } catch (NoSuchElementException nsee) {
-                 // Object was borrowed in another thread
-                 // Don't count this as an eviction test so reduce i;
-                 i--;
-                 evictionIterator = null;
-                 continue;
-             }
+        for (int i = 0, m = getNumTests(); i < m; i++) {
+            if(evictionIterator == null || !evictionIterator.hasNext()) {
+                if (evictionKeyIterator == null ||
+                        !evictionKeyIterator.hasNext()) {
+                    List<K> keyCopy = new ArrayList<K>();
+                    keyCopy.addAll(poolKeyList);
+                    evictionKeyIterator = keyCopy.iterator();
+                }
+                while (evictionKeyIterator.hasNext()) {
+                    evictionKey = evictionKeyIterator.next();
+                    ObjectDeque<T> objectDeque = poolMap.get(evictionKey);
+                    if (objectDeque == null) {
+                        continue;
+                    }
+                    idleObjects = objectDeque.getIdleObjects();
+                    
+                    if (getLifo()) {
+                        evictionIterator = idleObjects.descendingIterator();
+                    } else {
+                        evictionIterator = idleObjects.iterator();
+                    }
+                    if (evictionIterator.hasNext()) {
+                        break;
+                    }
+                    evictionIterator = null;
+                }
+            }
+            if (evictionIterator == null) {
+                // Pools exhausted
+                return;
+            }
+            try {
+                underTest = evictionIterator.next();
+            } catch (NoSuchElementException nsee) {
+                // Object was borrowed in another thread
+                // Don't count this as an eviction test so reduce i;
+                i--;
+                evictionIterator = null;
+                continue;
+            }
 
-             if (!underTest.startEvictionTest()) {
-                 // Object was borrowed in another thread
-                 // Don't count this as an eviction test so reduce i;
-                 i--;
-                 continue;
-             }
+            if (!underTest.startEvictionTest()) {
+                // Object was borrowed in another thread
+                // Don't count this as an eviction test so reduce i;
+                i--;
+                continue;
+            }
 
-             if (idleEvictTime < underTest.getIdleTimeMillis()) {
-                 destroy(evictionKey, underTest);
-             } else {
-                 if (testWhileIdle) {
-                     boolean active = false;
-                     try {
-                         _factory.activateObject(evictionKey, 
-                                 underTest.getObject());
-                         active = true;
-                     } catch (Exception e) {
-                         destroy(evictionKey, underTest);
-                     }
-                     if (active) {
-                         if (!_factory.validateObject(evictionKey,
-                                 underTest.getObject())) {
-                             destroy(evictionKey, underTest);
-                         } else {
-                             try {
-                                 _factory.passivateObject(evictionKey,
-                                         underTest.getObject());
-                             } catch (Exception e) {
-                                 destroy(evictionKey, underTest);
-                             }
-                         }
-                     }
-                 }
-                 if (!underTest.endEvictionTest(idleObjects)) {
-                     // TODO - May need to add code here once additional states
-                     // are used
-                 }
-             }
-         }
-     }
+            if (idleEvictTime < underTest.getIdleTimeMillis()) {
+                destroy(evictionKey, underTest);
+            } else {
+                if (testWhileIdle) {
+                    boolean active = false;
+                    try {
+                        _factory.activateObject(evictionKey, 
+                                underTest.getObject());
+                        active = true;
+                    } catch (Exception e) {
+                        destroy(evictionKey, underTest);
+                    }
+                    if (active) {
+                        if (!_factory.validateObject(evictionKey,
+                                underTest.getObject())) {
+                            destroy(evictionKey, underTest);
+                        } else {
+                            try {
+                                _factory.passivateObject(evictionKey,
+                                        underTest.getObject());
+                            } catch (Exception e) {
+                                destroy(evictionKey, underTest);
+                            }
+                        }
+                    }
+                }
+                if (!underTest.endEvictionTest(idleObjects)) {
+                    // TODO - May need to add code here once additional states
+                    // are used
+                }
+            }
+        }
+    }
 
      
-    /**
-     * TODO: Remove the force parameters along with support for when exhausted
-     * grow.
-     */
-    private PooledObject<T> create(K key, boolean force) throws Exception {
+    private PooledObject<T> create(K key) throws Exception {
         int maxActive = getMaxActive(); // Per key
         int maxTotal = getMaxTotal();   // All keys
 
@@ -1564,7 +1549,7 @@ public class GenericKeyedObjectPool<K,T>
         
         while (loop) {
             int newNumTotal = numTotal.incrementAndGet();
-            if (!force && maxTotal > -1 && newNumTotal > maxTotal) {
+            if (maxTotal > -1 && newNumTotal > maxTotal) {
                 numTotal.decrementAndGet();
                 if (getNumIdle() == 0) {
                     return null;
@@ -1577,10 +1562,11 @@ public class GenericKeyedObjectPool<K,T>
         }
          
         ObjectDeque<T> objectDeque = poolMap.get(key);
-        int newNumActive = objectDeque.getNumActive().incrementAndGet();
+        long newCreateCount = objectDeque.getCreateCount().incrementAndGet();
 
         // Check against the per key limit
-        if (!force && maxActive > -1 && newNumActive > maxActive) {
+        if (maxActive > -1 && newCreateCount > maxActive ||
+                newCreateCount > Integer.MAX_VALUE) {
             numTotal.decrementAndGet();
             return null;
         }
@@ -1611,7 +1597,7 @@ public class GenericKeyedObjectPool<K,T>
             try {
                 _factory.destroyObject(key, toDestory.getObject());
             } finally {
-                objectDeque.getNumActive().decrementAndGet();
+                objectDeque.getCreateCount().decrementAndGet();
                 numTotal.decrementAndGet();
             }
         } finally {
@@ -1654,12 +1640,12 @@ public class GenericKeyedObjectPool<K,T>
         // TODO Think carefully about when a read lock is required
         objectDeque = poolMap.get(k);
         long numInterested = objectDeque.getNumInterested().decrementAndGet();
-        if (numInterested == 0 && objectDeque.getNumActive().get() == 0) {
+        if (numInterested == 0 && objectDeque.getCreateCount().get() == 0) {
             // Potential to remove key
             Lock lock = keyLock.writeLock();
             lock.lock();
             try {
-                if (objectDeque.getNumActive().get() == 0 &&
+                if (objectDeque.getCreateCount().get() == 0 &&
                         objectDeque.getNumInterested().get() == 0) {
                     poolMap.remove(k);
                     poolKeyList.remove(k);
@@ -1768,7 +1754,7 @@ public class GenericKeyedObjectPool<K,T>
         }
         register(key);
         try {
-            PooledObject<T> p = create(key, false);
+            PooledObject<T> p = create(key);
             addIdleObject(key, p);
         } finally {
             deregister(key);
@@ -1883,7 +1869,7 @@ public class GenericKeyedObjectPool<K,T>
         private final LinkedBlockingDeque<PooledObject<S>> idleObjects =
                 new LinkedBlockingDeque<PooledObject<S>>();
 
-        private AtomicInteger numActive = new AtomicInteger(0);
+        private AtomicInteger createCount = new AtomicInteger(0);
 
         private Map<S, PooledObject<S>> allObjects =
                 new ConcurrentHashMap<S, PooledObject<S>>();
@@ -1894,8 +1880,8 @@ public class GenericKeyedObjectPool<K,T>
             return idleObjects;
         }
         
-        public AtomicInteger getNumActive() {
-            return numActive;
+        public AtomicInteger getCreateCount() {
+            return createCount;
         }
         
         public AtomicLong getNumInterested() {

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=1104552&r1=1104551&r2=1104552&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 Tue May 17 20:52:29 2011
@@ -23,7 +23,7 @@ import java.util.NoSuchElementException;
 import java.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.pool2.BaseObjectPool;
 import org.apache.commons.pool2.ObjectPool;
@@ -1238,7 +1238,7 @@ public class GenericObjectPool<T> extend
                 p = _idleObjects.pollFirst();
                 if (p == null) {
                     create = true;
-                    p = create(false);
+                    p = create();
                 }
                 if (p == null) {
                     throw new NoSuchElementException("Pool exhausted");
@@ -1250,7 +1250,7 @@ public class GenericObjectPool<T> extend
                 p = _idleObjects.pollFirst();
                 if (p == null) {
                     create = true;
-                    p = create(false);
+                    p = create();
                 }
                 if (p == null) {
                     if (maxWait < 1) {
@@ -1267,15 +1267,6 @@ public class GenericObjectPool<T> extend
                 if (!p.allocate()) {
                     p = null;
                 }
-            } else if (whenExhaustedAction == WhenExhaustedAction.GROW) {
-                p = _idleObjects.pollFirst();
-                if (p == null) {
-                    create = true;
-                    p = create(true);
-                }
-                if (!p.allocate()) {
-                    p = null;
-                }
             }
 
             if (p != null) {
@@ -1624,14 +1615,11 @@ public class GenericObjectPool<T> extend
         return;
     }
 
-    /**
-     * TODO: Remove the force parameters along with support for when exhausted
-     * grow.
-     */
-    private PooledObject<T> create(boolean force) throws Exception {
+    private PooledObject<T> create() throws Exception {
         int maxActive = getMaxActive();
-        int newNumActive = createCount.incrementAndGet();
-        if (!force && maxActive > -1 && newNumActive > maxActive) {
+        long newCreateCount = createCount.incrementAndGet();
+        if (maxActive > -1 && newCreateCount > maxActive ||
+                newCreateCount > Integer.MAX_VALUE) {
             createCount.decrementAndGet();
             return null;
         }
@@ -1673,7 +1661,7 @@ public class GenericObjectPool<T> extend
         }
 
         while (_idleObjects.size() < minIdle) {
-            PooledObject<T> p = create(false);
+            PooledObject<T> p = create();
             if (p == null) {
                 // Can't create objects, no reason to think another call to
                 // create will work. Give up.
@@ -1698,7 +1686,7 @@ public class GenericObjectPool<T> extend
             throw new IllegalStateException(
                     "Cannot add objects without a factory.");
         }
-        PooledObject<T> p = create(false);
+        PooledObject<T> p = create();
         addIdleObject(p);
     }
 
@@ -2040,7 +2028,7 @@ public class GenericObjectPool<T> extend
      * {@link #create(boolean)} will ensure that there are never more than
      * {@link #_maxActive} objects created at any one time.
      */
-    private AtomicInteger createCount = new AtomicInteger(0);
+    private AtomicLong createCount = new AtomicLong(0);
 
     /** The queue of idle objects */
     private LinkedBlockingDeque<PooledObject<T>> _idleObjects = null;

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java?rev=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java Tue May 17 20:52:29 2011
@@ -38,11 +38,5 @@ public enum WhenExhaustedAction {
      * {@link GenericKeyedObjectPool#getMaxWait maximum wait time} has been
      * reached.
      */
-    BLOCK,
-
-    /**
-     * The {@code borrowObject()} method should simply create a
-     * new object anyway.
-     */
-    GROW
+    BLOCK
 }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Tue May 17 20:52:29 2011
@@ -230,16 +230,6 @@ public class TestGenericKeyedObjectPool 
     }
 
     @Test
-    public void testWhenExhaustedGrow() throws Exception {
-        pool.setMaxActive(1);
-        pool.setMaxTotal(1);
-        pool.setWhenExhaustedAction(WhenExhaustedAction.GROW);
-        for (int i = 0; i < 10; i++) {
-            pool.borrowObject("a");
-        }
-    }
-
-    @Test
     public void testMaxTotal() throws Exception {
         pool.setMaxActive(2);
         pool.setMaxTotal(3);
@@ -397,8 +387,6 @@ public class TestGenericKeyedObjectPool 
             assertEquals(WhenExhaustedAction.BLOCK,pool.getWhenExhaustedAction());
             pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
             assertEquals(WhenExhaustedAction.FAIL,pool.getWhenExhaustedAction());
-            pool.setWhenExhaustedAction(WhenExhaustedAction.GROW);
-            assertEquals(WhenExhaustedAction.GROW,pool.getWhenExhaustedAction());
         }
     }
 
@@ -1016,7 +1004,7 @@ public class TestGenericKeyedObjectPool 
         boolean testOnReturn = true;
         boolean testWhileIdle = true;
         long timeBetweenEvictionRunsMillis = 8;
-        WhenExhaustedAction whenExhaustedAction = WhenExhaustedAction.GROW;
+        WhenExhaustedAction whenExhaustedAction = WhenExhaustedAction.FAIL;
         boolean lifo = false;
         
         GenericKeyedObjectPool<Object,Object> pool = new GenericKeyedObjectPool<Object,Object>();

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java?rev=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java Tue May 17 20:52:29 2011
@@ -55,7 +55,7 @@ public class TestGenericKeyedObjectPoolF
         config.testOnReturn = false;
         config.testWhileIdle = true;
         config.timeBetweenEvictionRunsMillis = 8;
-        config.whenExhaustedAction = WhenExhaustedAction.GROW;
+        config.whenExhaustedAction = WhenExhaustedAction.FAIL;
         config.lifo = false;
         factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), config);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
@@ -70,7 +70,7 @@ public class TestGenericKeyedObjectPoolF
         assertEquals(true, pool.getTestWhileIdle());
         assertEquals(false, pool.getLifo());
         assertEquals(8, pool.getTimeBetweenEvictionRunsMillis());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
@@ -88,47 +88,47 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, true, false);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, true, false);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, 4);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
         assertEquals(4, pool.getMaxTotal());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, true, false);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, true, false, 4, 5, 6, false);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false, 4, 5, 6, false);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
@@ -139,11 +139,11 @@ public class TestGenericKeyedObjectPoolF
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
         assertEquals(false, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, 4, true, false, 5, 6, 7, true);
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
@@ -155,7 +155,7 @@ public class TestGenericKeyedObjectPoolF
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
         assertEquals(true, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.close();
     }
 }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java Tue May 17 20:52:29 2011
@@ -76,19 +76,6 @@ public class TestGenericObjectPool exten
     }
 
     @Test
-    public void testWhenExhaustedGrow() throws Exception {
-        pool.setMaxActive(1);
-        pool.setWhenExhaustedAction(WhenExhaustedAction.GROW);
-        Object obj1 = pool.borrowObject();
-        assertNotNull(obj1);
-        Object obj2 = pool.borrowObject();
-        assertNotNull(obj2);
-        pool.returnObject(obj2);
-        pool.returnObject(obj1);
-        pool.close();
-    }
-
-    @Test
     public void testWhenExhaustedFail() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
@@ -737,8 +724,6 @@ public class TestGenericObjectPool exten
             assertEquals(WhenExhaustedAction.BLOCK,pool.getWhenExhaustedAction());
             pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
             assertEquals(WhenExhaustedAction.FAIL,pool.getWhenExhaustedAction());
-            pool.setWhenExhaustedAction(WhenExhaustedAction.GROW);
-            assertEquals(WhenExhaustedAction.GROW,pool.getWhenExhaustedAction());
         }
     }
     
@@ -769,7 +754,7 @@ public class TestGenericObjectPool exten
             expected.testOnReturn = true;
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected);
             assertConfiguration(expected,pool);
         }
@@ -783,7 +768,7 @@ public class TestGenericObjectPool exten
             GenericObjectPool.Config expected = new GenericObjectPool.Config();
             expected.maxActive = 2;
             expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait);
             assertConfiguration(expected,pool);
         }
@@ -793,7 +778,7 @@ public class TestGenericObjectPool exten
             expected.maxWait = 5L;
             expected.testOnBorrow = true;
             expected.testOnReturn = true;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.testOnBorrow,expected.testOnReturn);
             assertConfiguration(expected,pool);
         }
@@ -802,7 +787,7 @@ public class TestGenericObjectPool exten
             expected.maxActive = 2;
             expected.maxIdle = 3;
             expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle);
             assertConfiguration(expected,pool);
         }
@@ -811,7 +796,7 @@ public class TestGenericObjectPool exten
             expected.maxActive = 2;
             expected.maxIdle = 3;
             expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             expected.testOnBorrow = true;
             expected.testOnReturn = true;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle,expected.testOnBorrow,expected.testOnReturn);
@@ -828,7 +813,7 @@ public class TestGenericObjectPool exten
             expected.testOnReturn = true;
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
             assertConfiguration(expected,pool);
         }
@@ -844,7 +829,7 @@ public class TestGenericObjectPool exten
             expected.testOnReturn = true;
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
             GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.minIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
             assertConfiguration(expected,pool);
         }
@@ -864,7 +849,7 @@ public class TestGenericObjectPool exten
         expected.testOnReturn = true;
         expected.testWhileIdle = true;
         expected.timeBetweenEvictionRunsMillis = 11L;
-        expected.whenExhaustedAction = WhenExhaustedAction.GROW;
+        expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
         pool.setConfig(expected);
         assertConfiguration(expected,pool);
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java?rev=1104552&r1=1104551&r2=1104552&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java Tue May 17 20:52:29 2011
@@ -61,7 +61,7 @@ public class TestGenericObjectPoolFactor
         config.testWhileIdle = true;
         config.lifo = false;
         config.timeBetweenEvictionRunsMillis = 8;
-        config.whenExhaustedAction = WhenExhaustedAction.GROW;
+        config.whenExhaustedAction = WhenExhaustedAction.FAIL;
         factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), config);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
@@ -76,7 +76,7 @@ public class TestGenericObjectPoolFactor
         assertEquals(true, pool.getTestWhileIdle());
         assertEquals(false, pool.getLifo());
         assertEquals(8, pool.getTimeBetweenEvictionRunsMillis());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
@@ -106,40 +106,40 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, true, false);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, true, false);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, true, false);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, true, false, 4, 5, 6, false);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false, 4, 5, 6, false);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
@@ -150,12 +150,12 @@ public class TestGenericObjectPoolFactor
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
         assertEquals(false, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, 4, true, false, 5, 6, 7, true);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
@@ -167,12 +167,12 @@ public class TestGenericObjectPoolFactor
         assertEquals(true, pool.getTestOnBorrow());
         assertEquals(false, pool.getTestOnReturn());
         assertEquals(true, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.GROW, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
         pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
@@ -186,7 +186,7 @@ public class TestGenericObjectPoolFactor
         assertEquals(false, pool.getTestOnReturn());
         assertEquals(true, pool.getTestWhileIdle());
         assertEquals(false, pool.getLifo());
-        assertEquals(WhenExhaustedAction.GROW, pool.getWhenExhaustedAction());
+        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
     }