commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Liu" <>
Subject Issues when using the Apache Commons Pool with testWhileIdle preperty and validateObject(Object obj) method
Date Fri, 24 Apr 2009 01:58:24 GMT


       I'm a java developer. I am now using Apache Commons Pool 1.4. I
encounter the following problems. I use PoolableObjectFactory and
GenericObjectPool. The configuration for GenericObjectPool is: 


       <bean id="pool"
class="org.apache.commons.pool.impl.GenericObjectPool" singleton="true">

              <property name="factory" ref="factory" />

              <property name="maxActive"><value>2</value></property>

              <property name="maxIdle"><value>-1</value></property>



              <property name="testWhileIdle"><value>true</value></property>

              <property name="testOnBorrow"><value>false</value></property>

              <property name="testOnReturn"><value>false</value></property>




I want to validate the idle objects using the method validateObject(Object
obj) of PoolableObjectFactory. In my configuration, when I get 1 connection
from the pool and return it to the pool, the idle object should 1. And every
1 minutes, the validateObject(Object obj) should call once. The fact is in
every minutes, the validateObject(Object obj) called times will increase 1.
Also, I found that the return value of method getNumIdle() will increase 1
every time I call it the method validateObject(Object obj), while the return
value of method getNumActive() will increase negative 1. But I think, the
return value of getNumIdle() should be 1 and the return value of
getNumActive should be 0 in this situation. How could I ensure
validateObject(Object obj) just call once every minutes in this situation?


Could you help me?





Gemini Mobile Technologies

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message