Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.26.1
-
None
-
None
Description
Javadocs specify that ZipArchiveOutputStream setEncoding(java.lang.String) with null should use the platform's default encoding. In 1.26.1 a null value throws an IllegalArgumentException.
import java.io.File; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; public class Main { public static void main(String[] args) throws Exception { ZipArchiveOutputStream zaos = new ZipArchiveOutputStream(new File("/dev/null")); zaos.setEncoding((String)null); System.out.println("Success"); } }
In commons-compress 1.26.0 and earlier this code prints "Success" and exits without exception.
In commons-compress 1.26.1 the result is a stack trace:
Exception in thread "main" java.lang.IllegalArgumentException: Null charset name at java.base/java.nio.charset.Charset.lookup(Charset.java:455) at java.base/java.nio.charset.Charset.forName(Charset.java:526) at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.setEncoding(ZipArchiveOutputStream.java:1340) at Main.main(Test:11)
This appears to be related to the change in the method implementation during 03c253335fe9c61f14eb9bb95324de1ec383ec48 2024-03-04 16:52:22