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 00986acf0911800f85afed1e0f66089df373716b Author: Gary Gregory <[email protected]> AuthorDate: Tue Aug 11 09:27:35 2026 -0400 [BZip2] BZip2CompressorInputStream now throw CompressorException (a subclass of IOException) instead of IllegalArgumetException/IllegalStateException. --- src/changes/changes.xml | 2 +- .../compressors/bzip2/BZip2CompressorInputStream.java | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b332f0ed8..db3f63136 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -68,7 +68,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory">[7-Zip] SevenZMethodConfiguration now throws ArchiveException instead of IllegalArgumetException/IllegalStateException.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">[7-Zip] SevenZOutputFile now throws ArchiveException instead of IllegalArgumetException/IllegalStateException.</action> <!-- FIX bzip2 --> - <action type="fix" dev="ggregory" due-to="Tyler Nighswander, Gary Gregory">[BZip2] BZip2CompressorInputStream now throw CompressorException (a subclass of IOException) for invalid or corrupted data, providing more specific error reporting.</action> + <action type="fix" dev="ggregory" due-to="Tyler Nighswander, Gary Gregory">[BZip2] BZip2CompressorInputStream now throw CompressorException (a subclass of IOException) instead of IllegalArgumetException/IllegalStateException.</action> <action type="fix" dev="pkarwasz" due-to="Tyler Nighswander, Piotr P. Karwasz">[BZip2] BZip2 input streams treat Huffman codes longer than 20 bits as corrupted data, matching the behavior of the reference implementation.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory, Oti">[BZip2] Fix NullPointerException at BZip2CompressorOutputStream.writeRun() #757.</action> <!-- FIX dump --> diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java index cb928d697..f943aab40 100644 --- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java @@ -608,30 +608,22 @@ private int read0() throws IOException { switch (currentState) { case EOF: return -1; - case START_BLOCK_STATE: return setupBlock(); - case RAND_PART_A_STATE: - throw new IllegalStateException(); - + throw new CompressorException("Unexpected RAND_PART_A_STATE in read0()"); case RAND_PART_B_STATE: return setupRandPartB(); - case RAND_PART_C_STATE: return setupRandPartC(); - case NO_RAND_PART_A_STATE: - throw new IllegalStateException(); - + throw new CompressorException("Unexpected NO_RAND_PART_A_STATE in read0()"); case NO_RAND_PART_B_STATE: return setupNoRandPartB(); - case NO_RAND_PART_C_STATE: return setupNoRandPartC(); - default: - throw new IllegalStateException(); + throw new CompressorException("Unexpected %s in read0()", currentState); } }
