Jeffrey Adamson created COMPRESS-677:
----------------------------------------

             Summary: ZipArchiveOutputStream:setEncoding(String) with a null 
value throws IllegalArgumentException
                 Key: COMPRESS-677
                 URL: https://issues.apache.org/jira/browse/COMPRESS-677
             Project: Commons Compress
          Issue Type: Bug
    Affects Versions: 1.26.1
            Reporter: Jeffrey Adamson


Javadocs specify that ZipArchiveOutputStream setEncoding(java.lang.String) 
should use the platform's default encoding. In 1.26.1 a null value throws an 
IllegalArgumentException.
{code:java}
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");    
    }
} {code}
In commons-compress 1.26.0 and earlier this code prints "Success" and exists 
without exception.

In commons-compress 1.26.1 the result is a stack trace:
{noformat}
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)
{noformat}
This appears to be related to the change in the method implementation during 
03c253335fe9c61f14eb9bb95324de1ec383ec48 2024-03-04 16:52:22



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to