Browse Source

NoteMapTest: Open TreeWalk instances in try-with-resource

Change-Id: I70da0140fe087e7e69c28e9ddd125495d916ec1b
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
tags/v4.3.0.201603230630-rc1
David Pursehouse 8 years ago
parent
commit
50e21322de
1 changed files with 12 additions and 8 deletions
  1. 12
    8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java

+ 12
- 8
org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java View File

@@ -403,10 +403,12 @@ public class NoteMapTest extends RepositoryTestCase {
}

RevCommit n = commitNoteMap(map);
TreeWalk tw = new TreeWalk(reader);
tw.reset(n.getTree());
while (tw.next())
assertFalse("no fan-out subtree", tw.isSubtree());
try (TreeWalk tw = new TreeWalk(reader)) {
tw.reset(n.getTree());
while (tw.next()) {
assertFalse("no fan-out subtree", tw.isSubtree());
}
}

for (int i = 254; i < 256; i++) {
idBuf.setByte(Constants.OBJECT_ID_LENGTH - 1, i);
@@ -418,13 +420,15 @@ public class NoteMapTest extends RepositoryTestCase {

// The 00 bucket is fully split.
String path = fanout(38, idBuf.name());
tw = TreeWalk.forPath(reader, path, n.getTree());
assertNotNull("has " + path, tw);
try (TreeWalk tw = TreeWalk.forPath(reader, path, n.getTree())) {
assertNotNull("has " + path, tw);
}

// The other bucket is not.
path = fanout(2, data1.name());
tw = TreeWalk.forPath(reader, path, n.getTree());
assertNotNull("has " + path, tw);
try (TreeWalk tw = TreeWalk.forPath(reader, path, n.getTree())) {
assertNotNull("has " + path, tw);
}
}

@Test

Loading…
Cancel
Save