commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Finnerty" <>
Subject RE: [patch] allow (enforce) zero idle objects in GenericObjectPool
Date Tue, 11 Mar 2003 15:31:35 GMT
Okay, I'll include it inline since something along the line is dropping the attachment.

Index: pool/src/java/org/apache/commons/pool/impl/
RCS file: /home/cvspublic/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/,v
retrieving revision 1.15
diff -u -r1.15
--- pool/src/java/org/apache/commons/pool/impl/	7 Mar 2003 20:28:36
-0000	1.15
+++ pool/src/java/org/apache/commons/pool/impl/	10 Mar 2003 21:24:23
@@ -86,7 +86,7 @@
  *  </li>
  *  <li>
  *    {@link #setMaxIdle <i>maxIdle</i>} controls the maximum number of objects
that can
- *    sit idle in the pool at any time.  When non-positive, there
+ *    sit idle in the pool at any time.  When negative, there
  *    is no limit to the number of objects that may be idle at one time.
  *  </li>
  *  <li>
@@ -815,7 +815,7 @@
         synchronized(this) {
-            if((_maxIdle > 0) && (_pool.size() >= _maxIdle)) {
+            if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) {
                 shouldDestroy = true;
             } else if(success) {
                 _pool.addFirst(new ObjectTimestampPair(obj));

-----Original Message-----
From: Scott Finnerty 
Sent: Monday, March 10, 2003 3:31 PM
Subject: [patch] allow (enforce) zero idle objects in GenericObjectPool

We have a situation where we are managing LDAP connections and want
to setup to use a pool to manage the connections.  In one deployment 
of the application, the LDAP server we are using does not allow 
connections to remain idle/open for any length of time, so we need 
to configure the pool to always hand out new connections and destroy 
them when they are returned.  We thought we could do this with a 
maxIdle setting of zero.  However GenericObjectPool will consider 
destroying an object if the maxIdle is greater than zero - forcing 
you to have at least one idle object in your pool.

The javadoc for GenericObjectPool states that a non-positive value for 
maxIdle implies an unlimited number of idle objects, while the javadoc 
for GenericObjectPool.setMaxIdle(int) states that a negative value for 
maxIdle implies an unlimited number of idle objects.  It seems that 
"non-positive" implies zero or less (<= 0) because that is how the 
code behaves.

I've attached a patch that changes the behavior to only enforce 
maxIdle if it is non-negative - thereby allowing a pool to have zero
idle objects.

Scott Finnerty
Technical Director
Direct: 816.512.9359

Digital Evergreen
423 West 8th Street
Kansas City, MO 64105
Phone: 816.512.9399

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message