]> source.dussan.org Git - jgit.git/commitdiff
ArchiveCommand: Create archive output stream in try-with-resource 63/118663/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 11:19:25 +0000 (20:19 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 11:19:25 +0000 (20:19 +0900)
Change-Id: I72f4d303945275d400723aa17212b302e051dc15
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java

index c29ed0e22d946ce7879f550d572dabc965071c7c..10397f8ac9032433c1da7cd06a6afbfe2356a11f 100644 (file)
@@ -392,9 +392,10 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
        private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) {
                try {
                        try (TreeWalk walk = new TreeWalk(repo);
-                                       RevWalk rw = new RevWalk(walk.getObjectReader())) {
+                                       RevWalk rw = new RevWalk(walk.getObjectReader());
+                                       T outa = fmt.createArchiveOutputStream(out,
+                                                       formatOptions)) {
                                String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$
-                               T outa = fmt.createArchiveOutputStream(out, formatOptions);
                                MutableObjectId idBuf = new MutableObjectId();
                                ObjectReader reader = walk.getObjectReader();
 
@@ -427,7 +428,6 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
                                        walk.getObjectId(idBuf, 0);
                                        fmt.putEntry(outa, tree, name, mode, reader.open(idBuf));
                                }
-                               outa.close();
                                return out;
                        } finally {
                                out.close();