From: Gustavo Martin Morcuende Date: Wed, 5 Oct 2016 01:03:06 +0000 (+0200) Subject: A few improvements X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=e6f720cc799c3e5537c49ffa2db1874be93cc931;p=WebAppTest%2F.git A few improvements --- diff --git a/src/main/java/com/prueba/core/context/integration/database/impl/DataBaseAccessImpl.java b/src/main/java/com/prueba/core/context/integration/database/impl/DataBaseAccessImpl.java index debe67a..2d85205 100644 --- a/src/main/java/com/prueba/core/context/integration/database/impl/DataBaseAccessImpl.java +++ b/src/main/java/com/prueba/core/context/integration/database/impl/DataBaseAccessImpl.java @@ -42,8 +42,7 @@ public class DataBaseAccessImpl implements DataBaseAccess { protected List> executeQueryThrowable( String query, ExecuteResultSet executeResultSet, FillPreparedStatement fillStatement) throws SQLException { - final Connection connection = this.dataSource.getConnection(); - try { + try (final Connection connection = this.dataSource.getConnection()) { return this.doExecuteQuery( query, connection, @@ -54,8 +53,6 @@ public class DataBaseAccessImpl implements DataBaseAccess { return preparedStatement.executeQuery(); }, executeResultSet); - } finally { - connection.close(); } } @@ -88,8 +85,7 @@ public class DataBaseAccessImpl implements DataBaseAccess { 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, @@ -99,8 +95,6 @@ public class DataBaseAccessImpl implements DataBaseAccess { preparedStatement.executeUpdate(); }); - } finally { - connection.close(); } } diff --git a/src/main/java/com/prueba/services/impl/LoginServiceImpl.java b/src/main/java/com/prueba/services/impl/LoginServiceImpl.java index dd3a6f0..05b885a 100644 --- a/src/main/java/com/prueba/services/impl/LoginServiceImpl.java +++ b/src/main/java/com/prueba/services/impl/LoginServiceImpl.java @@ -31,7 +31,8 @@ public class LoginServiceImpl { 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);