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
The following commit(s) were added to refs/heads/master by this push: new 98017a23 Use try-with-resources block. 98017a23 is described below commit 98017a2378d74d5a0a3c7fdb8c60a2d9b476efef Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Apr 28 17:05:11 2023 -0400 Use try-with-resources block. Test does not need hack on file close call. --- .../commons/io/output/DeferredFileOutputStreamTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java index d1e44b53..a2b14437 100644 --- a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java @@ -407,19 +407,14 @@ public class DeferredFileOutputStreamTest { * @param testFile The file containing the test output. */ private void verifyResultFile(final File testFile) throws IOException { - final InputStream fis = Files.newInputStream(testFile.toPath()); - assertEquals(testBytes.length, fis.available()); + try (final InputStream fis = Files.newInputStream(testFile.toPath())) { + assertEquals(testBytes.length, fis.available()); - final byte[] resultBytes = new byte[testBytes.length]; - assertEquals(testBytes.length, fis.read(resultBytes)); + final byte[] resultBytes = new byte[testBytes.length]; + assertEquals(testBytes.length, fis.read(resultBytes)); - assertArrayEquals(resultBytes, testBytes); - assertEquals(-1, fis.read(resultBytes)); - - try { - fis.close(); - } catch (final IOException e) { - // Ignore an exception on close + assertArrayEquals(resultBytes, testBytes); + assertEquals(-1, fis.read(resultBytes)); } } }