ObjectDirectoryTest: ensure WindowCursor is closed
Change-Id: I75b7d36181a0d404d4e3dca17b9e436892d97b42
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
index 746a0a1..d1342c0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
@@ -243,17 +243,18 @@
db.getConfig().setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
ConfigConstants.CONFIG_KEY_WRITE_COMMIT_GRAPH, true);
- WindowCursor curs = new WindowCursor(db.getObjectDatabase());
- assertTrue(curs.getCommitGraph().isEmpty());
- commitFile("file.txt", "content", "master");
- GC gc = new GC(db);
- gc.gc().get();
- assertTrue(curs.getCommitGraph().isPresent());
+ try (WindowCursor curs = new WindowCursor(db.getObjectDatabase())) {
+ assertTrue(curs.getCommitGraph().isEmpty());
+ commitFile("file.txt", "content", "master");
+ GC gc = new GC(db);
+ gc.gc().get();
+ assertTrue(curs.getCommitGraph().isPresent());
- db.getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
- ConfigConstants.CONFIG_COMMIT_GRAPH, false);
+ db.getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_COMMIT_GRAPH, false);
- assertTrue(curs.getCommitGraph().isEmpty());
+ assertTrue(curs.getCommitGraph().isEmpty());
+ }
}
@Test