From 8ae0feb7dba8a318830bb99e1d18d3a7f6069918 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Tue, 16 Jun 2020 23:03:44 +0300 Subject: [PATCH] [java] Using try-with-resources to automatically close prepared statements (forgot to change this one in revious commits) --- .../selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/server/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java b/java/server/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java index 6ad859f077573..7e1aa50001ff2 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java +++ b/java/server/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java @@ -131,8 +131,8 @@ public Session get(SessionId id) throws NoSuchSessionException { public void remove(SessionId id) { Require.nonNull("Session ID", id); - try { - getDeleteSqlForSession(id).executeUpdate(); + try (PreparedStatement statement = getDeleteSqlForSession(id)) { + statement.executeUpdate(); } catch (SQLException e) { throw new JdbcException(e.getMessage()); }