Browse Source

CommitOnlyTest: Open RevWalk in try-with-resource

Change-Id: Ia3db8696f66f8d294e1d443fb54e716d26d517b1
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
625a21f5f4
  1. 10
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

10
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 "";
}

Loading…
Cancel
Save