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-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new efde2b52 Use try-with-resources
efde2b52 is described below

commit efde2b520808c2c758edcb8f1feee2e4b3799342
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Feb 5 11:35:54 2023 -0500

    Use try-with-resources
---
 .../compress/archivers/zip/UTF8ZipFilesTest.java   | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java 
b/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
index bf416542..2ec3cecf 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
@@ -328,24 +328,16 @@ public class UTF8ZipFilesTest extends AbstractTestCase {
 
     @Test
     public void testReadWinZipArchiveForStream() throws IOException {
-        final InputStream archive =
-            Files.newInputStream(getFile("utf8-winzip-test.zip").toPath());
-        ZipArchiveInputStream zi = null;
-        try {
-            // fix for test fails on Windows with default charset that is not 
UTF-8
-            String encoding = null;
-            if (Charset.defaultCharset() != UTF_8) {
-                encoding = UTF_8.name();
-            }
-
-            zi = new ZipArchiveInputStream(archive, encoding, true);
+        // fix for test fails on Windows with default charset that is not UTF-8
+        String encoding = null;
+        if (Charset.defaultCharset() != UTF_8) {
+            encoding = UTF_8.name();
+        }
+        try (InputStream archive = newInputStream("utf8-winzip-test.zip");
+                ZipArchiveInputStream zi = new ZipArchiveInputStream(archive, 
encoding, true)) {
             assertEquals(EURO_FOR_DOLLAR_TXT, zi.getNextEntry().getName());
             assertEquals(OIL_BARREL_TXT, zi.getNextEntry().getName());
             assertEquals(ASCII_TXT, zi.getNextEntry().getName());
-        } finally {
-            if (zi != null) {
-                zi.close();
-            }
         }
     }
 

Reply via email to