You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/04/25 13:52:00 UTC

[jira] [Resolved] (COMPRESS-677) ZipArchiveOutputStream.setEncoding(String) with a null value throws IllegalArgumentException

     [ https://issues.apache.org/jira/browse/COMPRESS-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory resolved COMPRESS-677.
--------------------------------------
    Fix Version/s: 1.26.2
       Resolution: Fixed

In git master and snapshot builds in https://repository.apache.org/content/repositories/snapshots/org/apache/commons/commons-compress/1.26.2-SNAPSHOT/


> 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
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 1.26.2
>
>
> 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.
> {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 exits 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)