You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/01 13:48:58 UTC

(commons-compress) branch master updated: Avoid possible NullPointerException in org.apache.commons.compress.utils.Sets.newHashSet(E...)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ac1be21f7 Avoid possible NullPointerException in org.apache.commons.compress.utils.Sets.newHashSet(E...)
ac1be21f7 is described below

commit ac1be21f71dccea6f968fe357884a852d9cbb31a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:48:52 2024 -0400

    Avoid possible NullPointerException in
    org.apache.commons.compress.utils.Sets.newHashSet(E...)
---
 src/changes/changes.xml                                   | 1 +
 src/main/java/org/apache/commons/compress/utils/Sets.java | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b957a16c6..529910753 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" issue="COMPRESS-665" dev="ggregory" due-to="Gary Gregory, Elliotte Rusty Harold">Deprecate org.apache.commons.compress.utils.CharsetNames in favor or java.nio.charset.StandardCharsets.</action>
       <action type="fix" issue="COMPRESS-674" dev="ggregory" due-to="Gren Elliot">Validate TarArchiveEntry checksums #500.</action>
       <action type="fix" issue="COMPRESS-676" dev="ecki" due-to="Martin Schneider">OSGi: Remove unresolvable dependencies in manifest and make the commons-io packages really optional.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.commons.compress.utils.Sets.newHashSet(E...).</action>
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 66 to 67 #495.</action>
       <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.ow2.asm:asm from 9.6 to 9.7 #504.</action>
diff --git a/src/main/java/org/apache/commons/compress/utils/Sets.java b/src/main/java/org/apache/commons/compress/utils/Sets.java
index 090206261..c2177642c 100644
--- a/src/main/java/org/apache/commons/compress/utils/Sets.java
+++ b/src/main/java/org/apache/commons/compress/utils/Sets.java
@@ -38,7 +38,7 @@ public class Sets {
      */
     @SafeVarargs
     public static <E> HashSet<E> newHashSet(final E... elements) {
-        final HashSet<E> set = new HashSet<>(elements.length);
+        final HashSet<E> set = new HashSet<>(elements != null ? elements.length : 0);
         Collections.addAll(set, elements);
         return set;
     }