Browse Source

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>
stable-5.0
David Pursehouse 7 years ago committed by Matthias Sohn
parent
commit
6eb4cd276c
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

7
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;
}

Loading…
Cancel
Save