Convert try to try-with-resource to silence Eclipse warning
Change-Id: I49c1add7e3510b9c3ca64dd304a7dd97868d6dba
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java
index 0757e29..7a65c72 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java
@@ -96,13 +96,7 @@
logger.atFinest().log("Calling phabricator method %s with the parameters %s", method, json);
httppost.setEntity(new StringEntity("params=" + json, StandardCharsets.UTF_8));
- CloseableHttpResponse response;
- try {
- response = getClient().execute(httppost);
- } catch (IOException e) {
- throw new ConduitException("Could not execute Phabricator API call", e);
- }
- try {
+ try (CloseableHttpResponse response = getClient().execute(httppost)) {
logger.atFinest().log("Phabricator HTTP response status: %s", response.getStatusLine());
HttpEntity entity = response.getEntity();
String entityString;
@@ -122,12 +116,8 @@
method, callCapsule.getErrorCode(), callCapsule.getErrorInfo());
}
return callCapsule.getResult();
- } finally {
- try {
- response.close();
- } catch (IOException e) {
- throw new ConduitException("Could not close API response", e);
- }
+ } catch (IOException e) {
+ throw new ConduitException("Could not execute Phabricator API call", e);
}
}
}