#7201 improve efforts to call listeners only when needed and guard against potential concurrent closures
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
fdeb03d556
commit
25306366d4
|
@ -459,13 +459,29 @@ public abstract class AbstractConnectionPool extends ContainerLifeCycle implemen
|
|||
@Override
|
||||
public void close()
|
||||
{
|
||||
// Manually release and remove entries to do our best effort calling the listeners.
|
||||
for (Pool<Connection>.Entry entry : pool.values())
|
||||
// Forcibly release and remove entries to do our best effort calling the listeners.
|
||||
try
|
||||
{
|
||||
if (entry.release())
|
||||
released(entry.getPooled());
|
||||
if (entry.remove())
|
||||
removed(entry.getPooled());
|
||||
for (Pool<Connection>.Entry entry : pool.values())
|
||||
{
|
||||
while (entry.isInUse())
|
||||
{
|
||||
if (entry.release())
|
||||
{
|
||||
released(entry.getPooled());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (entry.remove())
|
||||
removed(entry.getPooled());
|
||||
}
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Detected concurrent modification while forcibly releasing the pooled connections", x);
|
||||
// We could not call the listeners for all entries, but at least the following
|
||||
// pool.close() call will still release all resources.
|
||||
}
|
||||
pool.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue