diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-04-02 00:58:13 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-04-02 00:58:13 +0200 |
commit | 81c84c088f85e5babe73e1799fe786bf32750a5a (patch) | |
tree | 9f05b729f383ec43cd27c57a22174647e618e3c1 /org.eclipse.jgit/src | |
parent | d94ce9c754b740defbd75230663d323f64cc9648 (diff) | |
download | jgit-81c84c088f85e5babe73e1799fe786bf32750a5a.tar.gz jgit-81c84c088f85e5babe73e1799fe786bf32750a5a.zip |
Use try-with-resources to close walks in ArchiveCommand
Change-Id: I77120d77a12f1bab5c918a23b0e3eac90e320b2b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java index 9014aaf1a2..713866dc53 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java @@ -365,13 +365,11 @@ public class ArchiveCommand extends GitCommand<OutputStream> { private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) { final String pfx = prefix == null ? "" : prefix; //$NON-NLS-1$ - final TreeWalk walk = new TreeWalk(repo); - try { + try (final TreeWalk walk = new TreeWalk(repo)) { final T outa = fmt.createArchiveOutputStream(out, formatOptions); - try { + try (final RevWalk rw = new RevWalk(walk.getObjectReader())) { final MutableObjectId idBuf = new MutableObjectId(); final ObjectReader reader = walk.getObjectReader(); - final RevWalk rw = new RevWalk(walk.getObjectReader()); walk.reset(rw.parseTree(tree)); if (!paths.isEmpty()) @@ -405,8 +403,6 @@ public class ArchiveCommand extends GitCommand<OutputStream> { // TODO(jrn): Throw finer-grained errors. throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfArchiveCommand, e); - } finally { - walk.release(); } } |