e the object... }
catch
(Exception e) {
// invalidate the object
pool.invalidateObject(key, obj);
// do not return the object to the pool twice
obj =
null
; }
finally
{
// make sure the object is returned to the pool
if
(
null
!= obj) { pool.returnObject(key, obj); } }
{@link KeyedObjectPool} implementations may choose to store at mostone instance per key value, or may choose to maintain a pool of instances for each key (essentially creating a {@link java.util.Map Map} of{@link ObjectPool pools}).
See {@link org.apache.commons.pool2.impl.GenericKeyedObjectPool GenericKeyedObjectPool} for an implementation.
@param < K> The type of keys maintained by this pool.
@param < V> Type of element pooled in this pool.
@see KeyedPooledObjectFactory
@see ObjectPool
@see org.apache.commons.pool2.impl.GenericKeyedObjectPool GenericKeyedObjectPool
@version $Revision: 1566605 $
@since 2.0