Author: markt Date: Wed Aug 17 12:34:56 2011 New Revision: 1158657 URL: http://svn.apache.org/viewvc?rev=1158657&view=rev Log: Replace WhenExhuastedAction with a boolean since it only has two values
Removed: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/WhenExhaustedAction.java Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java 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/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/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java?rev=1158657&r1=1158656&r2=1158657&view=diff ============================================================================== --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java (original) +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java Wed Aug 17 12:34:56 2011 @@ -73,10 +73,9 @@ public abstract class BaseObjectPoolConf public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = -1L; /** - * The default "when exhausted action" for the pool. + * The default "block when exhausted" value for the pool. */ - public static final WhenExhaustedAction DEFAULT_WHEN_EXHAUSTED_ACTION = - WhenExhaustedAction.BLOCK; + public static final boolean DEFAULT_BLOCK_WHEN_EXHAUSTED = true; private boolean lifo = DEFAULT_LIFO; @@ -97,8 +96,7 @@ public abstract class BaseObjectPoolConf private long timeBetweenEvictionRunsMillis = DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS; - private WhenExhaustedAction whenExhaustedAction = - DEFAULT_WHEN_EXHAUSTED_ACTION; + private boolean blockWhenExhausted = DEFAULT_BLOCK_WHEN_EXHAUSTED; public boolean getLifo() { return lifo; @@ -164,11 +162,11 @@ public abstract class BaseObjectPoolConf this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; } - public WhenExhaustedAction getWhenExhaustedAction() { - return whenExhaustedAction; + public boolean getBlockWhenExhausted() { + return blockWhenExhausted; } - public void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction) { - this.whenExhaustedAction = whenExhaustedAction; + public void setBlockWhenExhausted(boolean blockWhenExhausted) { + this.blockWhenExhausted = blockWhenExhausted; } } 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=1158657&r1=1158656&r2=1158657&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 Aug 17 12:34:56 2011 @@ -240,7 +240,7 @@ public class GenericKeyedObjectPool<K,T> this._testWhileIdle = config.getTestWhileIdle(); this._timeBetweenEvictionRunsMillis = config.getTimeBetweenEvictionRunsMillis(); - this._whenExhaustedAction = config.getWhenExhaustedAction(); + this.blockWhenExhausted = config.getBlockWhenExhausted(); startEvictor(getMinEvictableIdleTimeMillis()); } @@ -304,8 +304,8 @@ public class GenericKeyedObjectPool<K,T> * @return the action to take when exhausted * @see #setWhenExhaustedAction */ - public WhenExhaustedAction getWhenExhaustedAction() { - return _whenExhaustedAction; + public boolean getBlockWhenExhausted() { + return blockWhenExhausted; } /** @@ -316,8 +316,8 @@ public class GenericKeyedObjectPool<K,T> * @param whenExhaustedAction the action to take when exhausted * @see #getWhenExhaustedAction */ - public void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction) { - _whenExhaustedAction = whenExhaustedAction; + public void setBlockWhenExhausted(boolean whenExhaustedAction) { + blockWhenExhausted = whenExhaustedAction; } @@ -597,7 +597,7 @@ public class GenericKeyedObjectPool<K,T> setMaxTotal(conf.getMaxTotal()); setMinIdlePerKey(conf.getMinIdlePerKey()); setMaxWait(conf.getMaxWait()); - setWhenExhaustedAction(conf.getWhenExhaustedAction()); + setBlockWhenExhausted(conf.getBlockWhenExhausted()); setTestOnBorrow(conf.getTestOnBorrow()); setTestOnReturn(conf.getTestOnReturn()); setTestWhileIdle(conf.getTestWhileIdle()); @@ -690,7 +690,7 @@ public class GenericKeyedObjectPool<K,T> // Get local copy of current config so it is consistent for entire // method execution - WhenExhaustedAction whenExhaustedAction = _whenExhaustedAction; + boolean blockWhenExhausted = this.blockWhenExhausted; boolean create; ObjectDeque<T> objectDeque = register(key); @@ -698,7 +698,7 @@ public class GenericKeyedObjectPool<K,T> try { while (p == null) { create = false; - if (whenExhaustedAction == WhenExhaustedAction.FAIL) { + if (blockWhenExhausted) { if (objectDeque != null) { p = objectDeque.getIdleObjects().pollFirst(); } @@ -706,13 +706,22 @@ public class GenericKeyedObjectPool<K,T> create = true; p = create(key); } + if (p == null && objectDeque != null) { + if (borrowMaxWait < 1) { + p = objectDeque.getIdleObjects().takeFirst(); + } else { + p = objectDeque.getIdleObjects().pollFirst( + borrowMaxWait, TimeUnit.MILLISECONDS); + } + } if (p == null) { - throw new NoSuchElementException("Pool exhausted"); + throw new NoSuchElementException( + "Timeout waiting for idle object"); } if (!p.allocate()) { p = null; } - } else if (whenExhaustedAction == WhenExhaustedAction.BLOCK) { + } else { if (objectDeque != null) { p = objectDeque.getIdleObjects().pollFirst(); } @@ -720,17 +729,8 @@ public class GenericKeyedObjectPool<K,T> create = true; p = create(key); } - if (p == null && objectDeque != null) { - if (borrowMaxWait < 1) { - p = objectDeque.getIdleObjects().takeFirst(); - } else { - p = objectDeque.getIdleObjects().pollFirst( - borrowMaxWait, TimeUnit.MILLISECONDS); - } - } if (p == null) { - throw new NoSuchElementException( - "Timeout waiting for idle object"); + throw new NoSuchElementException("Pool exhausted"); } if (!p.allocate()) { p = null; @@ -1627,16 +1627,15 @@ public class GenericKeyedObjectPool<K,T> private long _maxWait = GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT; /** - * The action to take when the {@link #borrowObject} method - * is invoked when the pool is exhausted (the maximum number - * of "active" objects has been reached). + * When the {@link #borrowObject} method is invoked when the pool is + * exhausted (the maximum number of "active" objects has been reached) + * should the {@link #borrowObject} method block or not? * - * @see #DEFAULT_WHEN_EXHAUSTED_ACTION * @see #setWhenExhaustedAction * @see #getWhenExhaustedAction */ - private WhenExhaustedAction _whenExhaustedAction = - GenericKeyedObjectPoolConfig.DEFAULT_WHEN_EXHAUSTED_ACTION; + private boolean blockWhenExhausted = + GenericKeyedObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED; /** * When <code>true</code>, objects will be 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=1158657&r1=1158656&r2=1158657&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 Aug 17 12:34:56 2011 @@ -193,7 +193,7 @@ public class GenericObjectPool<T> extend this.testWhileIdle = config.getTestWhileIdle(); this.timeBetweenEvictionRunsMillis = config.getTimeBetweenEvictionRunsMillis(); - this.whenExhaustedAction = config.getWhenExhaustedAction(); + this.blockWhenExhausted = config.getBlockWhenExhausted(); startEvictor(timeBetweenEvictionRunsMillis); } @@ -240,8 +240,8 @@ public class GenericObjectPool<T> extend * @return the action to take when the pool is exhuasted * @see #setWhenExhaustedAction */ - public WhenExhaustedAction getWhenExhaustedAction() { - return whenExhaustedAction; + public boolean getBlockWhenExhausted() { + return blockWhenExhausted; } /** @@ -252,9 +252,8 @@ public class GenericObjectPool<T> extend * @param whenExhaustedAction action to take when the pool is exhausted * @see #getWhenExhaustedAction */ - public void setWhenExhaustedAction( - WhenExhaustedAction whenExhaustedAction) { - this.whenExhaustedAction = whenExhaustedAction; + public void setBlockWhenExhausted(boolean blockWhenExhausted) { + this.blockWhenExhausted = blockWhenExhausted; } /** @@ -601,7 +600,7 @@ public class GenericObjectPool<T> extend setMinIdle(conf.getMinIdle()); setMaxTotal(conf.getMaxTotal()); setMaxWait(conf.getMaxWait()); - setWhenExhaustedAction(conf.getWhenExhaustedAction()); + setBlockWhenExhausted(conf.getBlockWhenExhausted()); setTestOnBorrow(conf.getTestOnBorrow()); setTestOnReturn(conf.getTestOnReturn()); setTestWhileIdle(conf.getTestWhileIdle()); @@ -680,25 +679,13 @@ public class GenericObjectPool<T> extend // Get local copy of current config so it is consistent for entire // method execution - WhenExhaustedAction exhaustedAction = whenExhaustedAction; + boolean blockWhenExhausted = this.blockWhenExhausted; boolean create; while (p == null) { create = false; - if (exhaustedAction == WhenExhaustedAction.FAIL) { - p = idleObjects.pollFirst(); - if (p == null) { - create = true; - p = create(); - } - if (p == null) { - throw new NoSuchElementException("Pool exhausted"); - } - if (!p.allocate()) { - p = null; - } - } else if (exhaustedAction == WhenExhaustedAction.BLOCK) { + if (blockWhenExhausted) { p = idleObjects.pollFirst(); if (p == null) { create = true; @@ -719,6 +706,18 @@ public class GenericObjectPool<T> extend if (!p.allocate()) { p = null; } + } else { + p = idleObjects.pollFirst(); + if (p == null) { + create = true; + p = create(); + } + if (p == null) { + throw new NoSuchElementException("Pool exhausted"); + } + if (!p.allocate()) { + p = null; + } } if (p != null) { @@ -1247,16 +1246,15 @@ public class GenericObjectPool<T> extend private volatile long maxWait = GenericObjectPoolConfig.DEFAULT_MAX_WAIT; /** - * The action to take when the {@link #borrowObject} method is invoked when - * the pool is exhausted (the maximum number of "active" objects has been - * reached). + * When the {@link #borrowObject} method is invoked when the pool is + * exhausted (the maximum number of "active" objects has been reached) + * should the {@link #borrowObject} method block or not? * - * @see #DEFAULT_WHEN_EXHAUSTED_ACTION * @see #setWhenExhaustedAction * @see #getWhenExhaustedAction */ - private volatile WhenExhaustedAction whenExhaustedAction = - GenericObjectPoolConfig.DEFAULT_WHEN_EXHAUSTED_ACTION; + private volatile boolean blockWhenExhausted = + GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED; /** * When <tt>true</tt>, objects will be 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=1158657&r1=1158656&r2=1158657&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 Wed Aug 17 12:34:56 2011 @@ -116,7 +116,7 @@ public class TestGenericKeyedObjectPool @Test public void testNegativeMaxTotalPerKey() throws Exception { pool.setMaxTotalPerKey(-1); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); String obj = pool.borrowObject(""); assertEquals("0",obj); pool.returnObject("",obj); @@ -210,7 +210,7 @@ public class TestGenericKeyedObjectPool @Test public void testMaxTotalPerKey() throws Exception { pool.setMaxTotalPerKey(3); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); pool.borrowObject(""); pool.borrowObject(""); @@ -226,7 +226,7 @@ public class TestGenericKeyedObjectPool @Test public void testMaxTotalPerKeyZero() throws Exception { pool.setMaxTotalPerKey(0); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); try { pool.borrowObject("a"); @@ -240,7 +240,7 @@ public class TestGenericKeyedObjectPool public void testMaxTotal() throws Exception { pool.setMaxTotalPerKey(2); pool.setMaxTotal(3); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); String o1 = pool.borrowObject("a"); assertNotNull(o1); @@ -281,7 +281,7 @@ public class TestGenericKeyedObjectPool @Test public void testMaxTotalZero() throws Exception { pool.setMaxTotal(0); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); try { pool.borrowObject("a"); @@ -389,10 +389,10 @@ public class TestGenericKeyedObjectPool assertEquals(11235L,pool.getTimeBetweenEvictionRunsMillis()); } { - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); - assertEquals(WhenExhaustedAction.BLOCK,pool.getWhenExhaustedAction()); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); - assertEquals(WhenExhaustedAction.FAIL,pool.getWhenExhaustedAction()); + pool.setBlockWhenExhausted(true); + assertEquals(true,pool.getBlockWhenExhausted()); + pool.setBlockWhenExhausted(false); + assertEquals(false,pool.getBlockWhenExhausted()); } } @@ -1015,7 +1015,7 @@ public class TestGenericKeyedObjectPool boolean testOnReturn = true; boolean testWhileIdle = true; long timeBetweenEvictionRunsMillis = 8; - WhenExhaustedAction whenExhaustedAction = WhenExhaustedAction.FAIL; + boolean blockWhenExhausted = false; boolean lifo = false; GenericKeyedObjectPool<Object,Object> pool = @@ -1037,8 +1037,8 @@ public class TestGenericKeyedObjectPool pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); - assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_WHEN_EXHAUSTED_ACTION, - pool.getWhenExhaustedAction()); + assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED, + pool.getBlockWhenExhausted()); assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_LIFO, pool.getLifo()); GenericKeyedObjectPoolConfig<Object,Object> config = @@ -1055,7 +1055,7 @@ public class TestGenericKeyedObjectPool config.setTestOnReturn(testOnReturn); config.setTestWhileIdle(testWhileIdle); config.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); - config.setWhenExhaustedAction(whenExhaustedAction); + config.setBlockWhenExhausted(blockWhenExhausted); pool = new GenericKeyedObjectPool<Object,Object>(null, config); assertEquals(maxTotalPerKey, pool.getMaxTotalPerKey()); assertEquals(maxIdle, pool.getMaxIdlePerKey()); @@ -1070,7 +1070,7 @@ public class TestGenericKeyedObjectPool assertEquals(testWhileIdle,pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); - assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction()); + assertEquals(blockWhenExhausted,pool.getBlockWhenExhausted()); assertEquals(lifo, pool.getLifo()); } @@ -1166,7 +1166,7 @@ public class TestGenericKeyedObjectPool SimpleFactory<String> factory = new SimpleFactory<String>(); GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setMaxWait(5000); pool.setMaxTotalPerKey(1); pool.setMaxTotal(-1); @@ -1212,7 +1212,7 @@ public class TestGenericKeyedObjectPool SimpleFactory<String> factory = new SimpleFactory<String>(); GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setMaxWait(maxWait); pool.setMaxTotalPerKey(threadsPerKey); // Create enough threads so half the threads will have to wait 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=1158657&r1=1158656&r2=1158657&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 Wed Aug 17 12:34:56 2011 @@ -55,7 +55,7 @@ public class TestGenericKeyedObjectPoolF config.setTestOnReturn(false); config.setTestWhileIdle(true); config.setTimeBetweenEvictionRunsMillis(8); - config.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + config.setBlockWhenExhausted(false); config.setLifo(false); GenericKeyedObjectPoolFactory<Object,Object> factory = new GenericKeyedObjectPoolFactory<Object,Object>( @@ -73,7 +73,7 @@ public class TestGenericKeyedObjectPoolF assertEquals(true, pool.getTestWhileIdle()); assertEquals(false, pool.getLifo()); assertEquals(8, pool.getTimeBetweenEvictionRunsMillis()); - assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction()); + assertEquals(false, pool.getBlockWhenExhausted()); 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=1158657&r1=1158656&r2=1158657&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 Wed Aug 17 12:34:56 2011 @@ -81,7 +81,7 @@ public class TestGenericObjectPool exten @Test public void testWhenExhaustedFail() throws Exception { pool.setMaxTotal(1); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); Object obj1 = pool.borrowObject(); assertNotNull(obj1); try { @@ -98,7 +98,7 @@ public class TestGenericObjectPool exten @Test public void testWhenExhaustedBlock() throws Exception { pool.setMaxTotal(1); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setMaxWait(10L); Object obj1 = pool.borrowObject(); assertNotNull(obj1); @@ -115,7 +115,7 @@ public class TestGenericObjectPool exten @Test public void testWhenExhaustedBlockInterupt() throws Exception { pool.setMaxTotal(1); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setMaxWait(0); Object obj1 = pool.borrowObject(); @@ -472,7 +472,7 @@ public class TestGenericObjectPool exten @Test public void testNegativeMaxTotal() throws Exception { pool.setMaxTotal(-1); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); Object obj = pool.borrowObject(); assertEquals(getNthObject(0),obj); pool.returnObject(obj); @@ -515,7 +515,7 @@ public class TestGenericObjectPool exten @Test public void testMaxTotal() throws Exception { pool.setMaxTotal(3); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); pool.borrowObject(); pool.borrowObject(); @@ -532,7 +532,7 @@ public class TestGenericObjectPool exten public void testTimeoutNoLeak() throws Exception { pool.setMaxTotal(2); pool.setMaxWait(10); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); Object obj = pool.borrowObject(); Object obj2 = pool.borrowObject(); try { @@ -551,7 +551,7 @@ public class TestGenericObjectPool exten @Test public void testMaxTotalZero() throws Exception { pool.setMaxTotal(0); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + pool.setBlockWhenExhausted(false); try { pool.borrowObject(); @@ -573,7 +573,7 @@ public class TestGenericObjectPool exten factory.setMaxTotal(maxTotal); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); pool.setMaxTotal(maxTotal); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setTimeBetweenEvictionRunsMillis(-1); // Start threads to borrow objects @@ -691,10 +691,10 @@ public class TestGenericObjectPool exten assertEquals(12135L,pool.getSoftMinEvictableIdleTimeMillis()); } { - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); - assertEquals(WhenExhaustedAction.BLOCK,pool.getWhenExhaustedAction()); - pool.setWhenExhaustedAction(WhenExhaustedAction.FAIL); - assertEquals(WhenExhaustedAction.FAIL,pool.getWhenExhaustedAction()); + pool.setBlockWhenExhausted(true); + assertEquals(true,pool.getBlockWhenExhausted()); + pool.setBlockWhenExhausted(false); + assertEquals(false,pool.getBlockWhenExhausted()); } } @@ -722,7 +722,7 @@ public class TestGenericObjectPool exten expected.setTestOnReturn(true); expected.setTestWhileIdle(true); expected.setTimeBetweenEvictionRunsMillis(11L); - expected.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + expected.setBlockWhenExhausted(false); pool.setConfig(expected); assertConfiguration(expected,pool); } @@ -1231,7 +1231,7 @@ public class TestGenericObjectPool exten assertEquals("testOnBorrow",expected.getTestOnBorrow(),actual.getTestOnBorrow()); assertEquals("testOnReturn",expected.getTestOnReturn(),actual.getTestOnReturn()); assertEquals("testWhileIdle",expected.getTestWhileIdle(),actual.getTestWhileIdle()); - assertEquals("whenExhaustedAction",expected.getWhenExhaustedAction(),actual.getWhenExhaustedAction()); + assertEquals("whenExhaustedAction",expected.getBlockWhenExhausted(),actual.getBlockWhenExhausted()); assertEquals("maxTotal",expected.getMaxTotal(),actual.getMaxTotal()); assertEquals("maxIdle",expected.getMaxIdle(),actual.getMaxIdle()); assertEquals("maxWait",expected.getMaxWait(),actual.getMaxWait()); @@ -1430,7 +1430,7 @@ public class TestGenericObjectPool exten int maxTotal = 10; pool.setMaxTotal(maxTotal); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setTimeBetweenEvictionRunsMillis(-1); // Start threads to borrow objects @@ -1474,7 +1474,7 @@ public class TestGenericObjectPool exten factory.setMaxTotal(maxTotal); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); pool.setMaxTotal(maxTotal); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setTestOnBorrow(true); // First borrow object will need to create a new object which will fail @@ -1570,7 +1570,7 @@ public class TestGenericObjectPool exten final int threads = 10; // number of threads to grab the object initially SimpleFactory factory = new SimpleFactory(); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); - pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK); + pool.setBlockWhenExhausted(true); pool.setMaxWait(maxWait); pool.setMaxTotal(threads); // Create enough threads so half the threads will have to wait 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=1158657&r1=1158656&r2=1158657&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 Wed Aug 17 12:34:56 2011 @@ -61,7 +61,7 @@ public class TestGenericObjectPoolFactor config.setTestWhileIdle(true); config.setLifo(false); config.setTimeBetweenEvictionRunsMillis(8); - config.setWhenExhaustedAction(WhenExhaustedAction.FAIL); + config.setBlockWhenExhausted(false); GenericObjectPoolFactory<Object> factory = new GenericObjectPoolFactory<Object>( @@ -81,7 +81,7 @@ public class TestGenericObjectPoolFactor assertEquals(true, pool.getTestWhileIdle()); assertEquals(false, pool.getLifo()); assertEquals(8, pool.getTimeBetweenEvictionRunsMillis()); - assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction()); + assertEquals(false, pool.getBlockWhenExhausted()); pool.borrowObject(); pool.close(); }