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-bcel.git

commit 80e862649d3ab6fb28ea55eacc772318b1182d06
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Apr 1 10:28:45 2024 -0400

    Avoid NullPointerException after calling
    
org.apache.bcel.classfile.ParameterAnnotations.setParameterAnnotationTable(ParameterAnnotationEntry[])
    with null
---
 src/changes/changes.xml                                           | 1 +
 src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c791986d..03e74af3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -71,6 +71,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.MethodParameters.setParameters(MethodParameter[]) 
with null.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.ParameterAnnotations.setParameterAnnotationTable(ParameterAnnotationEntry[])
 with null.</action>
       <!-- UPDATE -->
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.apache.commons:commons-parent from 66 to 67 
#283.</action>
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.22 to 
1.9.23 #284.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java 
b/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
index 390d0391..615e163b 100644
--- a/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
@@ -29,6 +29,8 @@ import java.util.stream.Stream;
  */
 public abstract class ParameterAnnotations extends Attribute implements 
Iterable<ParameterAnnotationEntry> {
 
+    private static final ParameterAnnotationEntry[] EMPTY_ARRAY = {};
+    
     /** Table of parameter annotations */
     private ParameterAnnotationEntry[] parameterAnnotationTable;
 
@@ -119,6 +121,6 @@ public abstract class ParameterAnnotations extends 
Attribute implements Iterable
      * @param parameterAnnotationTable the entries to set in this parameter 
annotation
      */
     public final void setParameterAnnotationTable(final 
ParameterAnnotationEntry[] parameterAnnotationTable) {
-        this.parameterAnnotationTable = parameterAnnotationTable;
+        this.parameterAnnotationTable = parameterAnnotationTable != null ? 
parameterAnnotationTable : EMPTY_ARRAY;
     }
 }

Reply via email to