diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-13 16:00:41 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-03-13 22:21:36 +0100 |
commit | 6eb4cd276c9cb8b6227c8ecb695106e2c226a2c3 (patch) | |
tree | b3aea4081f650e5add9dcd2401d8c8072c470893 | |
parent | 9450a55f76461b2b6d28f332b922d6dbc3247a64 (diff) | |
download | jgit-6eb4cd276c9cb8b6227c8ecb695106e2c226a2c3.tar.gz jgit-6eb4cd276c9cb8b6227c8ecb695106e2c226a2c3.zip |
AmazonS3: Refactor error method to avoid 'should be managed by try-with-resource' warning
Change-Id: I205fc1c77777870b0a036e52fa9954de5d9f60b5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java index 71e3d16c47..740a284302 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java @@ -524,12 +524,11 @@ public class AmazonS3 { JGitText.get().amazonS3ActionFailed, action, key, Integer.valueOf(HttpSupport.response(c)), c.getResponseMessage())); - final InputStream errorStream = c.getErrorStream(); - if (errorStream == null) { + if (c.getErrorStream() == null) { return err; } - try { + try (InputStream errorStream = c.getErrorStream()) { final ByteArrayOutputStream b = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; for (;;) { @@ -545,8 +544,6 @@ public class AmazonS3 { if (buf.length > 0) { err.initCause(new IOException("\n" + new String(buf))); //$NON-NLS-1$ } - } finally { - errorStream.close(); } return err; } |