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 { 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}");
final TreeWalk tw = TreeWalk.forPath(repo, path, try (RevWalk rw = new RevWalk(repo)) {
new RevWalk(repo).parseTree(headId)); final TreeWalk tw = TreeWalk.forPath(repo, path,
return new String(tw.getObjectReader().open(tw.getObjectId(0)) rw.parseTree(headId));
.getBytes()); return new String(tw.getObjectReader().open(tw.getObjectId(0))
.getBytes());
}
} catch (Exception e) { } catch (Exception e) {
return ""; return "";
} }

Loading…
Cancel
Save