Author: markt
Date: Wed Aug 31 21:39:15 2011
New Revision: 1163834
URL: http://svn.apache.org/viewvc?rev=1163834&view=rev
Log:
Change meaning of maxWait
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/test/org/apache/commons/pool2/impl/TestGenericObjectPool.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=1163834&r1=1163833&r2=1163834&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Wed Aug 31 21:39:15 2011
@@ -80,6 +80,10 @@
<action dev="markt" type="update" issue="POOL-98">
Add additional attributes (also accessible via JMX) for monitoring.
</action>
+ <action dev="markt" type="update">
+ Change meaning of zero for maxWait to a maximum wait of zero milliseconds
+ rather than the unexpected infinite wait.
+ </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=1163834&r1=1163833&r2=1163834&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 31 21:39:15 2011
@@ -101,10 +101,10 @@ import org.apache.commons.pool2.PoolUtil
* When {@link #getBlockWhenExhausted} is true,
* {@link #borrowObject borrowObject} will block
* (invoke {@link Object#wait() wait} until a new or idle object is
available.
- * If a positive {@link #setMaxWait maxWait}
+ * If a non-negative {@link #setMaxWait maxWait}
* value is supplied, the {@link #borrowObject borrowObject} will block
for at
* most that many milliseconds, after which a {@link
NoSuchElementException}
- * will be thrown. If {@link #setMaxWait maxWait} is non-positive,
+ * will be thrown. If {@link #setMaxWait maxWait} is negative,
* the {@link #borrowObject borrowObject} method will block indefinitely.
* </li>
* </ul>
@@ -376,7 +376,7 @@ public class GenericKeyedObjectPool<K,T>
* an exception when the pool is exhausted and the
* {@link #getBlockWhenExhausted} is true.
*
- * When less than or equal to 0, the {@link #borrowObject} method
+ * When less than 0, the {@link #borrowObject} method
* may block indefinitely.
*
* @return the maximum number of milliseconds borrowObject will block.
@@ -393,7 +393,7 @@ public class GenericKeyedObjectPool<K,T>
* an exception when the pool is exhausted and the
* {@link #getBlockWhenExhausted} is true.
*
- * When less than or equal to 0, the {@link #borrowObject} method
+ * When less than 0, the {@link #borrowObject} method
* may block indefinitely.
*
* @param maxWait the maximum number of milliseconds borrowObject will
block or negative for indefinitely.
@@ -753,7 +753,7 @@ public class GenericKeyedObjectPool<K,T>
p = create(key);
}
if (p == null && objectDeque != null) {
- if (borrowMaxWait < 1) {
+ if (borrowMaxWait < 0) {
p = objectDeque.getIdleObjects().takeFirst();
} else {
waitTime = System.currentTimeMillis();
@@ -1788,7 +1788,7 @@ public class GenericKeyedObjectPool<K,T>
* an exception when the pool is exhausted and the
* {@link #getBlockWhenExhausted} is true.
*
- * When less than or equal to 0, the {@link #borrowObject} method
+ * When less than 0, the {@link #borrowObject} method
* may block indefinitely.
*
* @see #setMaxWait
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=1163834&r1=1163833&r2=1163834&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 31 21:39:15 2011
@@ -70,11 +70,11 @@ import org.apache.commons.pool2.Poolable
* {@link #borrowObject} will throw a {@link NoSuchElementException}</li>
* <li>When {@link #getBlockWhenExhausted} is true,
* {@link #borrowObject} will block (invoke
- * {@link Object#wait()}) until a new or idle object is available. If a
positive
- * {@link #setMaxWait <i>maxWait</i>} value is supplied, then
+ * {@link Object#wait()}) until a new or idle object is available. If a
+ * non-negative {@link #setMaxWait <i>maxWait</i>} value is supplied, then
* {@link #borrowObject} will block for at most that many milliseconds, after
* which a {@link NoSuchElementException} will be thrown. If {@link #setMaxWait
- * <i>maxWait</i>} is non-positive, the {@link #borrowObject} method will block
+ * <i>maxWait</i>} is negative, the {@link #borrowObject} method will block
* indefinitely.</li>
* </ul>
* The default {@link #getBlockWhenExhausted} is true
@@ -310,7 +310,7 @@ public class GenericObjectPool<T> extend
* Returns the maximum amount of time (in milliseconds) the
* {@link #borrowObject} method should block before throwing an exception
* when the pool is exhausted and the {@link #getBlockWhenExhausted} is
true.
- * When less than or equal to 0, the {@link #borrowObject} method may
block indefinitely.
+ * When less than 0, the {@link #borrowObject} method may block
indefinitely.
*
* @return maximum number of milliseconds to block when borrowing an
object.
* @see #setMaxWait
@@ -324,7 +324,7 @@ public class GenericObjectPool<T> extend
* Sets the maximum amount of time (in milliseconds) the
* {@link #borrowObject} method should block before throwing an exception
* when the pool is exhausted and the {@link #getBlockWhenExhausted} is
true.
- * When less than or equal to 0, the {@link #borrowObject} method may
block indefinitely.
+ * When less than 0, the {@link #borrowObject} method may block
indefinitely.
*
* @param maxWait
* maximum number of milliseconds to block when borrowing an
@@ -739,7 +739,7 @@ public class GenericObjectPool<T> extend
p = create();
}
if (p == null) {
- if (borrowMaxWait < 1) {
+ if (borrowMaxWait < 0) {
p = idleObjects.takeFirst();
} else {
waitTime = System.currentTimeMillis();
@@ -1388,7 +1388,7 @@ public class GenericObjectPool<T> extend
* The maximum amount of time (in millis) the {@link #borrowObject} method
* should block before throwing an exception when the pool is exhausted and
* {@link #getBlockWhenExhausted()} is true.
- * When less than or equal to 0, the
+ * When less than 0, the
* {@link #borrowObject} method may block indefinitely.
*
* @see #setMaxWait
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=1163834&r1=1163833&r2=1163834&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 31 21:39:15 2011
@@ -116,7 +116,7 @@ public class TestGenericObjectPool exten
public void testWhenExhaustedBlockInterupt() throws Exception {
pool.setMaxTotal(1);
pool.setBlockWhenExhausted(true);
- pool.setMaxWait(0);
+ pool.setMaxWait(-1);
Object obj1 = pool.borrowObject();
// Make sure on object was obtained