AMQ-7403: Potential PreparedStatement/ResultSet leak in LeaseDatabaseLocker#determineTimeDifference

This commit is contained in:
Pascal Schumacher 2020-02-11 21:11:25 +01:00
parent 6417d62f60
commit 26a0f8214c
1 changed files with 12 additions and 11 deletions

View File

@ -133,8 +133,8 @@ public class LeaseDatabaseLocker extends AbstractJDBCLocker {
}
protected long determineTimeDifference(Connection connection) throws SQLException {
PreparedStatement statement = connection.prepareStatement(getStatements().getCurrentDateTime());
ResultSet resultSet = statement.executeQuery();
try (PreparedStatement statement = connection.prepareStatement(getStatements().getCurrentDateTime());
ResultSet resultSet = statement.executeQuery()) {
long result = 0l;
if (resultSet.next()) {
Timestamp timestamp = resultSet.getTimestamp(1);
@ -147,6 +147,7 @@ public class LeaseDatabaseLocker extends AbstractJDBCLocker {
}
return result;
}
}
public void doStop(ServiceStopper stopper) throws Exception {
if (lockable.getBrokerService() != null && lockable.getBrokerService().isRestartRequested()) {