This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 346b447976cd5b8f66f231205ae94893ab97269d Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Oct 27 14:47:17 2023 -0400 Use try-with-resources --- .../commons/io/input/NullInputStreamTest.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java index 6e4aa60c..9e562ba7 100644 --- a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java @@ -185,16 +185,16 @@ public class NullInputStreamTest { @Test public void testSkip() throws Exception { - final InputStream input = new TestNullInputStream(10, true, false); - assertEquals(0, input.read(), "Read 1"); - assertEquals(1, input.read(), "Read 2"); - assertEquals(5, input.skip(5), "Skip 1"); - assertEquals(7, input.read(), "Read 3"); - assertEquals(2, input.skip(5), "Skip 2"); // only 2 left to skip - assertEquals(-1, input.skip(5), "Skip 3 (EOF)"); // End of file - - final IOException e = assertThrows(IOException.class, () -> input.skip(5), "Expected IOException for skipping after end of file"); - assertEquals("Skip after end of file", e.getMessage(), "Skip after EOF IOException message"); - input.close(); + try (InputStream input = new TestNullInputStream(10, true, false)) { + assertEquals(0, input.read(), "Read 1"); + assertEquals(1, input.read(), "Read 2"); + assertEquals(5, input.skip(5), "Skip 1"); + assertEquals(7, input.read(), "Read 3"); + assertEquals(2, input.skip(5), "Skip 2"); // only 2 left to skip + assertEquals(-1, input.skip(5), "Skip 3 (EOF)"); // End of file + + final IOException e = assertThrows(IOException.class, () -> input.skip(5), "Expected IOException for skipping after end of file"); + assertEquals("Skip after end of file", e.getMessage(), "Skip after EOF IOException message"); + } } }