Skip to content

Commit c0bc5cb

Browse files
committed
Use try-with-resources on DataHandle in FileHandleTest
1 parent 9554f8f commit c0bc5cb

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/test/java/org/scijava/io/handle/FileHandleTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,18 @@ public void testExists() throws IOException {
7979
final boolean deleted = delete(nonExistentFile);
8080

8181
final FileLocation loc = new FileLocation(nonExistentFile);
82-
final DataHandle<?> handle = dhs.create(loc);
83-
assertTrue(handle instanceof FileHandle);
84-
if (deleted) {
85-
assertFalse(handle.exists());
86-
assertEquals(-1, handle.length());
82+
try (final DataHandle<?> handle = dhs.create(loc)) {
83+
assertTrue(handle instanceof FileHandle);
84+
if (deleted) {
85+
assertFalse(handle.exists());
86+
assertEquals(-1, handle.length());
87+
}
88+
89+
handle.writeBoolean(true);
90+
assertTrue(handle.exists());
91+
assertEquals(1, handle.length());
8792
}
8893

89-
handle.writeBoolean(true);
90-
assertTrue(handle.exists());
91-
assertEquals(1, handle.length());
92-
9394
// Clean up.
9495
delete(nonExistentFile);
9596
}

0 commit comments

Comments
 (0)