mirror of https://github.com/apache/activemq.git
AMQ-7403: Potential PreparedStatement/ResultSet leak in LeaseDatabaseLocker#determineTimeDifference
This commit is contained in:
parent
6417d62f60
commit
26a0f8214c
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue