[java] Auto-closing a result set after use
@@ -145,7 +145,7 @@ public Session get(SessionId id) throws NoSuchSessionException {
span.setAttribute(DATABASE_STATEMENT, statement.toString());
span.setAttribute(DATABASE_OPERATION, "select");
- ResultSet sessions = statement.executeQuery();
+ try (ResultSet sessions = statement.executeQuery()) {
if (!sessions.next()) {
span.setAttribute("error", true);
span.setStatus(Status.NOT_FOUND);
@@ -160,6 +160,8 @@ public Session get(SessionId id) throws NoSuchSessionException {
caps = rawCapabilities == null ?
new ImmutableCapabilities() :
JSON.toType(rawCapabilities, Capabilities.class);
+ }
+
try {
uri = new URI(rawUri);
} catch (URISyntaxException e) {
