diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java index 2ace2e3ce..146a25ed3 100644 --- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java +++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java @@ -61,11 +61,12 @@ public class LFSPointerTest { final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10"; AnyLongObjectId id = LongObjectId.fromString(s); LfsPointer ptr = new LfsPointer(id, 4); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ptr.encode(baos); - baos.close(); - assertEquals("version https://git-lfs.github.com/spec/v1\noid sha256:" - + s + "\nsize 4\n", - baos.toString(UTF_8.name())); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + ptr.encode(baos); + assertEquals( + "version https://git-lfs.github.com/spec/v1\noid sha256:" + + s + "\nsize 4\n", + baos.toString(UTF_8.name())); + } } }