Currently I am using Apache Commons Pool 1.6 to manage a GenericKeyedObjectPool pool of connections. I have seen threads both throwing exceptions and hanging indefinitely both of which lead to the borrowed connections being leaked from the pool. I have corrected the leaking of connections in the case of exceptions being thrown using returnObject() but ideally I would like some way for the pool to manage this and retrieve hung or leaked connections.
From my investigation so far Commons Pool 1.x does not provide this functionality and that Commons Pool 2.x does but so far I cannot find how this is done.
How are borrowed connections pulled back into the pool when hung or leaked using Apache Commons Pool 2?
Thanks