mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +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();
|
Connection connection = dataSource.getConnection();
|
||||||
if (!connection.isValid(5)) {
|
if (!connection.isValid(5)) {
|
||||||
connection.close();
|
connection.close();
|
||||||
dataSource.close();
|
|
||||||
try {
|
try {
|
||||||
setupDataSource();
|
return getConnection();
|
||||||
// get new connection after restarting pool
|
} catch (StackOverflowError databaseHasGoneDown) {
|
||||||
connection = dataSource.getConnection();
|
throw new DBOpException("Valid connection could not be fetched (Is MySQL down?) - attempted until StackOverflowError occurred.", databaseHasGoneDown);
|
||||||
} catch (DBInitException e) {
|
|
||||||
throw new DBOpException("Failed to restart DataSource after a connection was invalid: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connection.getAutoCommit()) connection.setAutoCommit(false);
|
if (connection.getAutoCommit()) connection.setAutoCommit(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user