From 625a21f5f47c5fd4fa4453934843f2dee0c5cc78 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 22 Jan 2016 14:57:21 +0900 Subject: [PATCH] CommitOnlyTest: Open RevWalk in try-with-resource Change-Id: Ia3db8696f66f8d294e1d443fb54e716d26d517b1 Signed-off-by: David Pursehouse --- .../tst/org/eclipse/jgit/api/CommitOnlyTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java index 336a33566..5f7434b41 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java @@ -1294,10 +1294,12 @@ public class CommitOnlyTest extends RepositoryTestCase { try { final Repository repo = git.getRepository(); final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); - final TreeWalk tw = TreeWalk.forPath(repo, path, - new RevWalk(repo).parseTree(headId)); - return new String(tw.getObjectReader().open(tw.getObjectId(0)) - .getBytes()); + try (RevWalk rw = new RevWalk(repo)) { + final TreeWalk tw = TreeWalk.forPath(repo, path, + rw.parseTree(headId)); + return new String(tw.getObjectReader().open(tw.getObjectId(0)) + .getBytes()); + } } catch (Exception e) { return ""; }