Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove object out from pool in apache common pool2

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?

like image 884
Santhosha S Avatar asked Aug 10 '26 13:08

Santhosha S


1 Answers

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

like image 131
Gabriel Hernandez Avatar answered Aug 12 '26 14:08

Gabriel Hernandez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!