You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/27 22:17:04 UTC

[commons-compress] 03/06: Use try-with-resources

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

commit 1d1051f5c8bfa0231726c201f29b9456262ad0ff
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 27 16:58:04 2022 -0500

    Use try-with-resources
---
 .../java/org/apache/commons/compress/archivers/DumpTestCase.java    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java b/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
index 7601651f..c1ddd435 100644
--- a/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
@@ -84,8 +84,8 @@ public final class DumpTestCase extends AbstractTestCase {
     }
 
     private void unarchiveAll(final File input) throws Exception {
-        final InputStream is = Files.newInputStream(input.toPath());
-        try (ArchiveInputStream in = ArchiveStreamFactory.DEFAULT.createArchiveInputStream("dump", is)) {
+        try (InputStream is = Files.newInputStream(input.toPath());
+                ArchiveInputStream in = ArchiveStreamFactory.DEFAULT.createArchiveInputStream("dump", is)) {
             ArchiveEntry entry = in.getNextEntry();
             while (entry != null) {
                 final File archiveEntry = new File(dir, entry.getName());
@@ -98,8 +98,6 @@ public final class DumpTestCase extends AbstractTestCase {
                 Files.copy(in, archiveEntry.toPath());
                 entry = in.getNextEntry();
             }
-        } finally {
-            is.close();
         }
     }
 }