in src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java [91:114]
public void connectionClosed(final ConnectionEvent event) {
final PooledConnection pc = (PooledConnection) event.getSource();
// if this event occurred because we were validating, or if this
// connection has been marked for removal, ignore it
// otherwise return the connection to the pool.
if (!validatingSet.contains(pc)) {
final PooledConnectionAndInfo pci = pcMap.get(pc);
if (pci == null) {
throw new IllegalStateException(NO_KEY_MESSAGE);
}
try {
pool.returnObject(pci.getUserPassKey(), pci);
} catch (final Exception e) {
System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + "NOT BE RETURNED TO THE POOL");
pc.removeConnectionEventListener(this);
try {
pool.invalidateObject(pci.getUserPassKey(), pci);
} catch (final Exception e3) {
System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci);
e3.printStackTrace();
}
}
}
}