commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Finnerty" <>
Subject [patch] allow (enforce) zero idle objects in GenericObjectPool
Date Mon, 10 Mar 2003 21:30:40 GMT
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

View raw message