]> source.dussan.org Git - jgit.git/commitdiff
FS: Open TemporaryBuffer in try-with-resource 50/118750/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 07:58:12 +0000 (16:58 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 07:58:12 +0000 (16:58 +0900)
Change-Id: I52e048e491e838b7f762a5b5f4d148e91049877c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

index b43a7612dea7d3d7d3357f4ead45c969e6775dbf..edcb9d7a6a7e96da7ba2a33af43bb584da0178ec 100644 (file)
@@ -1227,14 +1227,11 @@ public abstract class FS {
         */
        public ExecutionResult execute(ProcessBuilder pb, InputStream in)
                        throws IOException, InterruptedException {
-               TemporaryBuffer stdout = new TemporaryBuffer.LocalFile(null);
-               TemporaryBuffer stderr = new TemporaryBuffer.Heap(1024, 1024 * 1024);
-               try {
+               try (TemporaryBuffer stdout = new TemporaryBuffer.LocalFile(null);
+                               TemporaryBuffer stderr = new TemporaryBuffer.Heap(1024,
+                                               1024 * 1024)) {
                        int rc = runProcess(pb, stdout, stderr, in);
                        return new ExecutionResult(stdout, stderr, rc);
-               } finally {
-                       stdout.close();
-                       stderr.close();
                }
        }