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. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

@ -1294,10 +1294,12 @@ public class CommitOnlyTest extends RepositoryTestCase {
try { try {
final Repository repo = git.getRepository(); final Repository repo = git.getRepository();
final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
try (RevWalk rw = new RevWalk(repo)) {
final TreeWalk tw = TreeWalk.forPath(repo, path, final TreeWalk tw = TreeWalk.forPath(repo, path,
new RevWalk(repo).parseTree(headId)); rw.parseTree(headId));
return new String(tw.getObjectReader().open(tw.getObjectId(0)) return new String(tw.getObjectReader().open(tw.getObjectId(0))
.getBytes()); .getBytes());
}
} catch (Exception e) { } catch (Exception e) {
return ""; return "";
} }

Loading…
Cancel
Save