Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-01-22 05:57:21 +0000
committerDavid Pursehouse2016-01-22 05:57:21 +0000
commit625a21f5f47c5fd4fa4453934843f2dee0c5cc78 (patch)
treecb8dcad5c97be5462bd06590bc7b52246720c8ef
parent84ac3cc3792ec164e304acf89d739bf724b619cc (diff)
downloadjgit-625a21f5f47c5fd4fa4453934843f2dee0c5cc78.tar.gz
jgit-625a21f5f47c5fd4fa4453934843f2dee0c5cc78.tar.xz
jgit-625a21f5f47c5fd4fa4453934843f2dee0c5cc78.zip
CommitOnlyTest: Open RevWalk in try-with-resource
Change-Id: Ia3db8696f66f8d294e1d443fb54e716d26d517b1 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java10
1 files 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 336a335663..5f7434b41f 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 "";
}

Back to the top