Continue with closing connections if an exception is thrown.

This commit is contained in:
akwizgran
2022-04-08 15:37:02 +01:00
parent a99ec5ed51
commit 9304a6b266

View File

@@ -641,12 +641,12 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
} }
void closeAllConnections() throws SQLException { void closeAllConnections() {
boolean interrupted = false; boolean interrupted = false;
connectionsLock.lock(); connectionsLock.lock();
try { try {
closed = true; closed = true;
for (Connection c : connections) c.close(); for (Connection c : connections) tryToClose(c, LOG, WARNING);
openConnections -= connections.size(); openConnections -= connections.size();
connections.clear(); connections.clear();
while (openConnections > 0) { while (openConnections > 0) {
@@ -656,7 +656,7 @@ abstract class JdbcDatabase implements Database<Connection> {
LOG.warning("Interrupted while closing connections"); LOG.warning("Interrupted while closing connections");
interrupted = true; interrupted = true;
} }
for (Connection c : connections) c.close(); for (Connection c : connections) tryToClose(c, LOG, WARNING);
openConnections -= connections.size(); openConnections -= connections.size();
connections.clear(); connections.clear();
} }