Hi, <quote>When testOnBorrow is set, the pool will attempt to validate each object before it is returned from the borrowObject() method. (Using the provided factory's PoolableObjectFactory.validateObject(java.lang.Object) method.) Objects that fail to validate will be dropped from the pool, and a different object will be borrowed. </quote> from api docs for org.apache.commons.pool.impl.GenericObjectPool
The last bit about "a different object will be borrowed" doesn't appear to work in my implementation. The life cycle I am experiencing with the borrowObject method is thus... call to borrowObject createObject is called ----> this is failing so I happen to return null object activateObject is called validateObject is called ---> this is checking to see if object is null (amongst other things) and returning false if null which is happening however, I am getting an exception java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:871) at uk.police.kent.pnc.PoolDemo.main(PoolDemo.java:23) thrown where I am expecting to get an attempt to create a different object and this one to be destroyed. The question is, what do I have to do to get this cycle to kick in on false being returned from validateObject??? Thanks Conrad