I have created GenericPool by extending GenericObjectPool and poolFactory using BasePooledObjectFactory. Now I want to remove the object from my Generic Pool.
.clear() will remove idleObject from pool how do we remove permanently from the pool?
Your poolFactory must implement the method
void destroyObject(PooledObject<T> p) throws Exception;
While your code should be calling method
public void invalidateObject(final T obj) throws Exception
on the GenericPool
At runtime, if you run into an exception situation (perhaps caused by a temp network issue) you need to remove the object from the pool and re-create it, so calling invalidateObject will destroy this object and automatically create new one when you call borrowObject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With