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 2025/08/03 20:24:42 UTC

(commons-compress) branch master updated: Use non-deprecated ArchiveException constructor

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 ee9215050 Use non-deprecated ArchiveException constructor
ee9215050 is described below

commit ee92150504992f0c525df9fd41c8eb1a79bc2282
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 3 16:24:37 2025 -0400

    Use non-deprecated ArchiveException constructor
---
 src/changes/changes.xml                                     |  1 +
 .../commons/compress/archivers/ar/ArArchiveInputStream.java | 13 ++++++-------
 .../commons/compress/archivers/tar/TarArchiveEntry.java     |  6 +++---
 .../compress/archivers/tar/TarArchiveInputStream.java       |  4 ++--
 .../org/apache/commons/compress/archivers/tar/TarFile.java  |  8 ++++----
 .../org/apache/commons/compress/archivers/tar/TarUtils.java |  4 ++--
 .../compress/archivers/zip/ExplodingInputStream.java        |  4 ++--
 .../compress/archivers/zip/ZipArchiveInputStream.java       |  4 ++--
 .../org/apache/commons/compress/archivers/zip/ZipFile.java  |  6 +++---
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b43f53dba..10c49d8a9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Normalize exception message sentences to start with a capital letter.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Classes in org.apache.commons.compress.archivers now throw a subclass of IOException called ArchiveException instead of IOException when a formatting problem is found.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Classes in org.apache.commons.compress.compressors now throw a subclass of IOException called CompressorException instead of IOException when a formatting problem is found.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Use non-deprecated ArchiveException constructor.</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.compress.MemoryLimitException.MemoryLimitException(long, long).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.compress.CompressException.CompressException(String, Object...).</action>
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index f44da0cf8..54f5e31cb 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -297,7 +297,6 @@ public ArArchiveEntry getNextArEntry() throws IOException {
                 throw new ArchiveException("Invalid entry trailer. not read the content? Occurred at byte: " + getBytesRead());
             }
         }
-
         entryOffset = offset;
         // GNU ar uses a '/' to mark the end of the file name; this allows for the use of spaces without the use of an extended file name.
         // entry name is stored as ASCII string
@@ -309,8 +308,8 @@ public ArArchiveEntry getNextArEntry() throws IOException {
         long len;
         try {
             len = asLong(metaData, LENGTH_OFFSET, LENGTH_LEN);
-        } catch (final NumberFormatException ex) {
-            throw new ArchiveException("Broken archive, unable to parse ar_size field as a number", ex);
+        } catch (final NumberFormatException e) {
+            throw new ArchiveException("Broken archive, unable to parse ar_size field as a number", (Throwable) e);
         }
         if (temp.endsWith("/")) { // GNU terminator
             temp = temp.substring(0, temp.length() - 1);
@@ -334,8 +333,8 @@ public ArArchiveEntry getNextArEntry() throws IOException {
                     asInt(metaData, GROUP_ID_OFFSET, GROUP_ID_LEN, true), asInt(metaData, FILE_MODE_OFFSET, FILE_MODE_LEN, 8),
                     asLong(metaData, LAST_MODIFIED_OFFSET, LAST_MODIFIED_LEN));
             return currentEntry;
-        } catch (final NumberFormatException ex) {
-            throw new ArchiveException("Broken archive, unable to parse entry metadata fields as numbers", ex);
+        } catch (final NumberFormatException e) {
+            throw new ArchiveException("Broken archive, unable to parse entry metadata fields as numbers", (Throwable) e);
         }
     }
 
@@ -390,8 +389,8 @@ private ArArchiveEntry readGNUStringTable(final byte[] length, final int offset,
         final int bufflen;
         try {
             bufflen = asInt(length, offset, len); // Assume length will fit in an int
-        } catch (final NumberFormatException ex) {
-            throw new ArchiveException("Broken archive, unable to parse GNU string table length field as a number", ex);
+        } catch (final NumberFormatException e) {
+            throw new ArchiveException("Broken archive, unable to parse GNU string table length field as a number", (Throwable) e);
         }
         namebuffer = IOUtils.readRange(in, bufflen);
         final int read = namebuffer.length;
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index be93580fe..b10f8bef5 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -279,7 +279,7 @@ private static Instant parseInstantFromDecimalSeconds(final String value) throws
         } catch (DateTimeException | ArithmeticException e) {
             // DateTimeException: Thrown if the instant exceeds the maximum or minimum instant.
             // ArithmeticException: Thrown if numeric overflow occurs.
-            throw new ArchiveException("Corrupted PAX header. Time field value is invalid '" + value + "'", e);
+            throw new ArchiveException("Corrupted PAX header. Time field value is invalid '" + value + "'", (Throwable) e);
         }
     }
 
@@ -1468,8 +1468,8 @@ private void parseTarHeader(final Map<String, String> globalPaxHeaders, final by
             final boolean lenient) throws IOException {
         try {
             parseUstarHeaderBlock(globalPaxHeaders, header, encoding, oldStyle, lenient);
-        } catch (final IllegalArgumentException ex) {
-            throw new ArchiveException("Corrupted TAR archive.", ex);
+        } catch (final IllegalArgumentException e) {
+            throw new ArchiveException("Corrupted TAR archive.", (Throwable) e);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
index 4bf91d04e..5ebdb552e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
@@ -440,7 +440,7 @@ public TarArchiveEntry getNextTarEntry() throws IOException {
         try {
             currEntry = new TarArchiveEntry(globalPaxHeaders, headerBuf, zipEncoding, lenient);
         } catch (final IllegalArgumentException e) {
-            throw new ArchiveException("Error detected parsing the header", e);
+            throw new ArchiveException("Error detected parsing the header", (Throwable) e);
         }
         entryOffset = 0;
         entrySize = currEntry.getSize();
@@ -477,7 +477,7 @@ public TarArchiveEntry getNextTarEntry() throws IOException {
                 applyPaxHeadersToCurrentEntry(globalPaxHeaders, globalSparseHeaders);
             }
         } catch (final NumberFormatException e) {
-            throw new ArchiveException("Error detected parsing the pax header", e);
+            throw new ArchiveException("Error detected parsing the pax header", (Throwable) e);
         }
         if (currEntry.isOldGNUSparse()) { // Process sparse files
             readOldGNUSparse();
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
index af05debfb..e90c4ee82 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
@@ -403,8 +403,8 @@ public List<TarArchiveEntry> getEntries() {
     public InputStream getInputStream(final TarArchiveEntry entry) throws IOException {
         try {
             return new BoundedTarEntryInputStream(entry, archive);
-        } catch (final RuntimeException ex) {
-            throw new ArchiveException("Corrupted TAR archive. Can't read entry", ex);
+        } catch (final RuntimeException e) {
+            throw new ArchiveException("Corrupted TAR archive. Can't read entry", (Throwable) e);
         }
     }
 
@@ -471,7 +471,7 @@ private TarArchiveEntry getNextTarEntry() throws IOException {
             final long position = archive.position();
             currEntry = new TarArchiveEntry(globalPaxHeaders, headerBuf.array(), zipEncoding, lenient, position);
         } catch (final IllegalArgumentException e) {
-            throw new ArchiveException("Error detected parsing the header", e);
+            throw new ArchiveException("Error detected parsing the header", (Throwable) e);
         }
 
         if (currEntry.isGNULongLinkEntry()) {
@@ -513,7 +513,7 @@ private TarArchiveEntry getNextTarEntry() throws IOException {
                 applyPaxHeadersToCurrentEntry(globalPaxHeaders, globalSparseHeaders);
             }
         } catch (final NumberFormatException e) {
-            throw new ArchiveException("Error detected parsing the pax header", e);
+            throw new ArchiveException("Error detected parsing the pax header", (Throwable) e);
         }
 
         if (currEntry.isOldGNUSparse()) { // Process sparse files
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 4a99b283e..671ae66c2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -792,9 +792,9 @@ static List<TarArchiveStructSparse> readSparseStructs(final byte[] buffer, final
                     throw new ArchiveException("Corrupted TAR archive, sparse entry with negative numbytes");
                 }
                 sparseHeaders.add(sparseHeader);
-            } catch (final IllegalArgumentException ex) {
+            } catch (final IllegalArgumentException e) {
                 // thrown internally by parseOctalOrBinary
-                throw new ArchiveException("Corrupted TAR archive, sparse entry is invalid", ex);
+                throw new ArchiveException("Corrupted TAR archive, sparse entry is invalid", (Throwable) e);
             }
         }
         return Collections.unmodifiableList(sparseHeaders);
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
index 2c683c524..93ccda2cf 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
@@ -194,8 +194,8 @@ public int read() throws IOException {
         if (!buffer.available()) {
             try {
                 fillBuffer();
-            } catch (final IllegalArgumentException ex) {
-                throw new ArchiveException("Bad IMPLODE stream", ex);
+            } catch (final IllegalArgumentException e) {
+                throw new ArchiveException("Bad IMPLODE stream", (Throwable) e);
             }
         }
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 67dd00aa3..550088168 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -780,8 +780,8 @@ public ZipArchiveEntry getNextZipEntry() throws IOException {
                     try {
                         current.inputStream = new ExplodingInputStream(current.entry.getGeneralPurposeBit().getSlidingDictionarySize(),
                                 current.entry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(), bis);
-                    } catch (final IllegalArgumentException ex) {
-                        throw new ArchiveException("Bad IMPLODE data", ex);
+                    } catch (final IllegalArgumentException e) {
+                        throw new ArchiveException("Bad IMPLODE data", (Throwable) e);
                     }
                     break;
                 case BZIP2:
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index fb0004e6e..1c4ce8fa6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -930,7 +930,7 @@ private ZipFile(final SeekableByteChannel channel, final String channelDescripti
             fillNameMap();
             success = true;
         } catch (final IOException e) {
-            throw new ArchiveException("Error reading Zip content from " + channelDescription, e);
+            throw new ArchiveException("Error reading Zip content from " + channelDescription, (Throwable) e);
         } finally {
             this.closed = !success;
             if (!success && closeOnError) {
@@ -1247,8 +1247,8 @@ public InputStream getInputStream(final ZipArchiveEntry entry) throws IOExceptio
             try {
                 return new ExplodingInputStream(entry.getGeneralPurposeBit().getSlidingDictionarySize(),
                         entry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(), is);
-            } catch (final IllegalArgumentException ex) {
-                throw new ArchiveException("Bad IMPLODE data", ex);
+            } catch (final IllegalArgumentException e) {
+                throw new ArchiveException("Bad IMPLODE data", (Throwable) e);
             }
         case DEFLATED:
             final Inflater inflater = new Inflater(true);