Skip to content

Commit fe400ac

Browse files
committed
Use try-with-resource in test
1 parent 4273ca8 commit fe400ac

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/test/java/com/maxmind/db/DecoderTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,8 @@ private static <T> void testTypeDecoding(Decoder.Type type, Map<T, byte[]> tests
439439
byte[] input = entry.getValue();
440440

441441
String desc = "decoded " + type.name() + " - " + expect;
442-
FileChannel fc = DecoderTest.getFileChannel(input);
443-
MappedByteBuffer mmap = fc.map(MapMode.READ_ONLY, 0, fc.size());
444-
try {
442+
try (FileChannel fc = DecoderTest.getFileChannel(input)) {
443+
MappedByteBuffer mmap = fc.map(MapMode.READ_ONLY, 0, fc.size());
445444

446445
Decoder decoder = new Decoder(cache, mmap, 0);
447446
decoder.POINTER_TEST_HACK = true;
@@ -471,8 +470,6 @@ private static <T> void testTypeDecoding(Decoder.Type type, Map<T, byte[]> tests
471470
} else {
472471
assertEquals(desc, expect, decoder.decode(0));
473472
}
474-
} finally {
475-
fc.close();
476473
}
477474
}
478475
}

0 commit comments

Comments
 (0)