Fix closing connection on invalid connection
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
bf1dde08c2
Commit
dbd91bf41a
@ -157,32 +157,36 @@ public class Statement implements AutoCloseable {
|
||||
|
||||
private <T> T withConnection(SQLRunnable<T> runnable, Object... objects) {
|
||||
Connection connection = aquireConnection();
|
||||
T result;
|
||||
|
||||
try {
|
||||
try {
|
||||
return tryWithConnection(connection, runnable, objects);
|
||||
} finally {
|
||||
if(connectionInvalid(connection)) {
|
||||
closeConnection(connection);
|
||||
} else {
|
||||
synchronized (connections) {
|
||||
connections.push(connection);
|
||||
connections.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
result = tryWithConnection(connection, runnable, objects);
|
||||
} catch (Throwable e) {
|
||||
if(connectionInvalid(connection)) {
|
||||
closeConnection(connection);
|
||||
|
||||
return withConnection(runnable, objects);
|
||||
} else {
|
||||
synchronized (connections) {
|
||||
connections.push(connection);
|
||||
connections.notify();
|
||||
}
|
||||
|
||||
throw new SecurityException("Failing sql statement", e);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (connections) {
|
||||
connections.push(connection);
|
||||
connections.notify();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean connectionInvalid(Connection connection) {
|
||||
try {
|
||||
return connection.isClosed();
|
||||
return connection.isClosed() || !connection.isValid(1);
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.INFO, "Could not check SQL connection status", e); // No database logging possible at this state
|
||||
return true;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren