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 97365da279788efbdc163a99bc567eb10f044208
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Feb 12 09:15:46 2024 -0500

    Use IOUtils.closeQuietly()
    
    Inline single use local variable
---
 .../commons/compress/harmony/unpack200/Archive.java | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java 
b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
index 287882171..6b41eff9e 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
@@ -31,6 +31,7 @@ import java.util.jar.JarOutputStream;
 import java.util.zip.GZIPInputStream;
 
 import org.apache.commons.compress.harmony.pack200.Pack200Exception;
+import org.apache.commons.io.IOUtils;
 
 /**
  * Archive is the main entry point to unpack200. An archive is constructed 
with either two file names, a pack file and an output file name or an input 
stream
@@ -202,26 +203,14 @@ public class Archive {
                 }
             }
         } finally {
-            try {
-                inputStream.close();
-            } catch (final Exception e) {
-            }
-            try {
-                outputStream.close();
-            } catch (final Exception e) {
-            }
-            if (logFile != null) {
-                try {
-                    logFile.close();
-                } catch (final Exception e) {
-                }
-            }
+            IOUtils.closeQuietly(inputStream);
+            IOUtils.closeQuietly(outputStream);
+            IOUtils.closeQuietly(logFile);
         }
         if (removePackFile) {
             boolean deleted = false;
             if (inputFileName != null) {
-                final File file = new File(inputFileName);
-                deleted = file.delete();
+                deleted = new File(inputFileName).delete();
             }
             if (!deleted) {
                 throw new Pack200Exception("Failed to delete the input file.");

Reply via email to