Comment #289 Hasten garbage collection of Connections after close

pull/295/head
Brett Wooldridge 10 years ago
parent dd371f3572
commit 62d3dd4074

@ -496,12 +496,14 @@ public class HikariPool implements HikariPoolMBean, IBagStateListener
if (tc < 0) { if (tc < 0) {
LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception()); LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception());
} }
final Connection connection = bagEntry.connection;
closeConnectionExecutor.execute(new Runnable() { closeConnectionExecutor.execute(new Runnable() {
public void run() { public void run() {
poolUtils.quietlyCloseConnection(bagEntry.connection, closureReason); poolUtils.quietlyCloseConnection(connection, closureReason);
} }
}); });
} }
bagEntry.connection = null;
} }
/** /**
@ -564,6 +566,7 @@ public class HikariPool implements HikariPoolMBean, IBagStateListener
poolUtils.quietlyCloseConnection(bagEntry.connection, "connection aborted during shutdown"); poolUtils.quietlyCloseConnection(bagEntry.connection, "connection aborted during shutdown");
} }
finally { finally {
bagEntry.connection = null;
if (connectionBag.remove(bagEntry)) { if (connectionBag.remove(bagEntry)) {
totalConnections.decrementAndGet(); totalConnections.decrementAndGet();
} }

Loading…
Cancel
Save