]> source.dussan.org Git - jgit.git/commitdiff
CommitOnlyTest: Open RevWalk in try-with-resource 49/64949/1
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Fri, 22 Jan 2016 05:57:21 +0000 (14:57 +0900)
committerDavid Pursehouse <david.pursehouse@sonymobile.com>
Fri, 22 Jan 2016 05:57:21 +0000 (14:57 +0900)
Change-Id: Ia3db8696f66f8d294e1d443fb54e716d26d517b1
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

index 336a335663a7ee8a093f106dab14392b395c3c24..5f7434b41fcf90613edd1b84b24e5f4f29b6c034 100644 (file)
@@ -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 "";
                }