From 50e21322de4c366da8c7f662b566b9ab1d06a960 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 12 Feb 2016 14:12:25 +0900 Subject: [PATCH] NoteMapTest: Open TreeWalk instances in try-with-resource Change-Id: I70da0140fe087e7e69c28e9ddd125495d916ec1b Signed-off-by: David Pursehouse --- .../org/eclipse/jgit/notes/NoteMapTest.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java index 4539a013f..47b08a7e1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java @@ -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