This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 07e5d650c13396582bfa6a7eeb913887126b486d
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Aug 11 09:34:19 2026 -0400

    [Deflate64] Deflate64Decoder now throws ArchiveException instead of
    IllegalArgumetException/IllegalStateException.
---
 src/changes/changes.xml                                    |  1 +
 .../compress/compressors/deflate64/Deflate64Decoder.java   | 14 +++++++-------
 .../compressors/deflate64/Deflate64DecoderTest.java        |  2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b2a08c7e0..56615cfb3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -150,6 +150,7 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- FIX deflate64 -->
       <action type="fix" dev="ggregory" due-to="KALI 834X, Gary 
Gregory">[Deflate64] Reject invalid literal/length and distance codes in 
Deflate64 decoder (#785).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">[Deflate64] 
Deflate64CompressorInputStream now throws ArchiveException instead of 
IllegalArgumetException/IllegalStateException.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">[Deflate64] 
Deflate64Decoder now throws ArchiveException instead of 
IllegalArgumetException/IllegalStateException.</action>
       <!-- FIX lz77 -->
       <action type="fix" dev="ggregory" due-to="KALI 834X, Gary 
Gregory">[LZ77] Reject back-reference offset larger than the window in lz77 
decoder class AbstractLZ77CompressorInputStream (#797).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">[LZ77] 
AbstractLZ77CompressorInputStream now throws ArchiveException instead of 
IllegalArgumetException/IllegalStateException.</action>
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/deflate64/Deflate64Decoder.java
 
b/src/main/java/org/apache/commons/compress/compressors/deflate64/Deflate64Decoder.java
index ee64475b3..1545c945d 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/deflate64/Deflate64Decoder.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/deflate64/Deflate64Decoder.java
@@ -87,13 +87,13 @@ private int incCounter(final int counter) {
             return newCounter;
         }
 
-        void recordToBuffer(final int distance, final int length, final byte[] 
buff) {
+        void recordToBuffer(final int distance, final int length, final byte[] 
buff) throws CompressorException {
             if (distance > memory.length) {
-                throw new IllegalStateException("Illegal distance parameter: " 
+ distance);
+                throw new CompressorException("Illegal distance parameter: " + 
distance);
             }
             final int start = wHead - distance & mask;
             if (!wrappedAround && start >= wHead) {
-                throw new IllegalStateException("Attempt to read beyond 
memory: dist=" + distance);
+                throw new CompressorException("Attempt to read beyond memory: 
dist=" + distance);
             }
             for (int i = 0, pos = start; i < length; i++, pos = 
incCounter(pos)) {
                 buff[i] = add(memory[pos]);
@@ -210,11 +210,11 @@ boolean hasData() {
         }
 
         @Override
-        int read(final byte[] b, final int off, final int len) {
+        int read(final byte[] b, final int off, final int len) throws 
CompressorException {
             if (len == 0) {
                 return 0;
             }
-            throw new IllegalStateException("Cannot read in this state");
+            throw new CompressorException("Cannot read in this state");
         }
 
         @Override
@@ -451,7 +451,7 @@ public int decode(final byte[] b, final int off, final int 
len) throws IOExcepti
                     state = new HuffmanCodes(DYNAMIC_CODES, tables[0], 
tables[1]);
                     break;
                 default:
-                    throw new IllegalStateException("Unsupported compression: 
" + mode);
+                    throw new CompressorException("Unsupported compression: " 
+ mode);
                 }
             } else {
                 final int r = state.read(b, off, len);
@@ -492,7 +492,7 @@ private void switchToUncompressedState() throws IOException 
{
         final long bNLen = readBits(16);
         if (((bLen ^ 0xFFFF) & 0xFFFF) != bNLen) {
             // noinspection DuplicateStringLiteralInspection
-            throw new IllegalStateException("Illegal LEN / NLEN values");
+            throw new CompressorException("Illegal LEN / NLEN values");
         }
         state = new UncompressedState(bLen);
     }
diff --git 
a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64DecoderTest.java
 
b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64DecoderTest.java
index f171fecf5..e4c661dcb 100644
--- 
a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64DecoderTest.java
+++ 
b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64DecoderTest.java
@@ -255,7 +255,7 @@ void testDecodeUncompressedBlockWithInvalidLenNLenValue() 
throws Exception {
                 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' };
         try (Deflate64Decoder decoder = new Deflate64Decoder(new 
ByteArrayInputStream(data))) {
             final byte[] result = new byte[100];
-            final IllegalStateException e = 
assertThrows(IllegalStateException.class, () -> {
+            final CompressorException e = 
assertThrows(CompressorException.class, () -> {
                 final int len = decoder.decode(result);
                 fail("Should have failed but returned " + len + " entries: " + 
Arrays.toString(Arrays.copyOf(result, len)));
             });

Reply via email to