aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-02-26 20:38:12 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-02-26 20:38:12 +0900
commit12a589fb577ebbd464cede7b06a7949c84a51350 (patch)
tree86a39dc729c85dcf72380d398e1e4018875a8fdb /org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
parentc2ff87e7869cad38d0ee505033d9439270b816d8 (diff)
downloadjgit-12a589fb577ebbd464cede7b06a7949c84a51350.tar.gz
jgit-12a589fb577ebbd464cede7b06a7949c84a51350.zip
AmazonS3: Open OutputStream in try-with-resource
Change-Id: I0685a298a0f9fec465973cc718ae3bff373318a4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java15
1 files changed, 5 insertions, 10 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 fee71eb362..0ed5d3c958 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
+++ b/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)) {