protected List<Map<String, String>> executeQueryThrowable(
String query, ExecuteResultSet<ResultSet> executeResultSet, FillPreparedStatement fillStatement) throws SQLException {
- final Connection connection = this.dataSource.getConnection();
- try {
+ try (final Connection connection = this.dataSource.getConnection()) {
return this.doExecuteQuery(
query,
connection,
return preparedStatement.executeQuery();
},
executeResultSet);
- } finally {
- connection.close();
}
}
protected void executeUpdateThrowable(
String query, FillPreparedStatement fillStatement) throws SQLException {
- final Connection connection = this.dataSource.getConnection();
- try {
+ try (final Connection connection = this.dataSource.getConnection()) {
this.doExecuteUpdate(
query,
connection,
preparedStatement.executeUpdate();
});
- } finally {
- connection.close();
}
}
public void processLogoutGet(HttpExchange httpExchange) throws IOException {
final Headers headers = httpExchange.getRequestHeaders();
- final String cookieValue = headers.getFirst(COOKIE_HEADER);
+ final String cookieValue = headers.getFirst(COOKIE_HEADER);
+
if (cookieValue != null) {
final UUID uuid = UUID.fromString(cookieValue);
Sessions.getInstance().removeSession(uuid);