mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Don't close DataSource with bad connection
- Attempt to recursively obtain a valid connection. This could lead to StackOverFlowException if db goes down, so that is caught. Affects issues: - Possibly fixed #1458
This commit is contained in:
parent
3335765fa2
commit
8423e392bb
@ -127,13 +127,10 @@ public class MySQLDB extends SQLDB {
|
||||
Connection connection = dataSource.getConnection();
|
||||
if (!connection.isValid(5)) {
|
||||
connection.close();
|
||||
dataSource.close();
|
||||
try {
|
||||
setupDataSource();
|
||||
// get new connection after restarting pool
|
||||
connection = dataSource.getConnection();
|
||||
} catch (DBInitException e) {
|
||||
throw new DBOpException("Failed to restart DataSource after a connection was invalid: " + e.getMessage(), e);
|
||||
return getConnection();
|
||||
} catch (StackOverflowError databaseHasGoneDown) {
|
||||
throw new DBOpException("Valid connection could not be fetched (Is MySQL down?) - attempted until StackOverflowError occurred.", databaseHasGoneDown);
|
||||
}
|
||||
}
|
||||
if (connection.getAutoCommit()) connection.setAutoCommit(false);
|
||||
|
Loading…
Reference in New Issue
Block a user