Skip to content

Commit

Permalink
clear closed Hikari connections
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiyvamz committed Dec 4, 2024
1 parent f3245e8 commit 279d373
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,20 @@ private void logConnectionQueue(final String host, final Queue<WeakReference<Con

public void pruneNullConnections() {
openedConnections.forEach((key, queue) -> {
queue.removeIf(connectionWeakReference -> Objects.equals(connectionWeakReference.get(), null));
queue.removeIf(connectionWeakReference -> {
final Connection conn = connectionWeakReference.get();
if (conn == null) {
return true;
}
if (conn.getClass().getSimpleName().equals("HikariProxyConnection")) {
try {
return conn.isClosed();
} catch (SQLException ex) {
return false;
}
}
return false;
});
});
}

Expand Down

0 comments on commit 279d373

Please sign in to comment.