Browse Source

AmazonS3: Open OutputStream in try-with-resource

Change-Id: I0685a298a0f9fec465973cc718ae3bff373318a4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
12a589fb57
  1. 15
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

15
org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

@ -402,9 +402,9 @@ public class AmazonS3 {
// We have to copy to produce the cipher text anyway so use
// the large object code path as it supports that behavior.
//
final OutputStream os = beginPut(bucket, key, null, null);
os.write(data);
os.close();
try (OutputStream os = beginPut(bucket, key, null, null)) {
os.write(data);
}
return;
}
@ -418,11 +418,8 @@ public class AmazonS3 {
authorize(c);
c.setDoOutput(true);
c.setFixedLengthStreamingMode(data.length);
final OutputStream os = c.getOutputStream();
try {
try (OutputStream os = c.getOutputStream()) {
os.write(data);
} finally {
os.close();
}
switch (HttpSupport.response(c)) {
@ -503,12 +500,10 @@ public class AmazonS3 {
authorize(c);
c.setDoOutput(true);
monitor.beginTask(monitorTask, (int) (len / 1024));
final OutputStream os = c.getOutputStream();
try {
try (OutputStream os = c.getOutputStream()) {
buf.writeTo(os, monitor);
} finally {
monitor.endTask();
os.close();
}
switch (HttpSupport.response(c)) {

Loading…
Cancel
Save