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/06/22 17:58:09 UTC

(commons-bcel) 08/25: Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl

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 2b3c043388074407cd05acc0e97b89f58efbed00
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Sat Jun 22 09:39:56 2024 -0400

    Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl
---
 src/changes/changes.xml           | 1 +
 src/examples/Mini/ASTFunAppl.java | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3485b1b0..353b07e5 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">SpotBugs checks should ignore code generated by JavaCC.</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs URF_UNREAD_FIELD in ClassDumper.</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl.</action>
       <!-- ADD --> 
       <action                  type="update" dev="ggregory" due-to="nbauma109, Gary Gregory, Mark Roberts">Add accessors to model and unit tests, Javadoc #183.</action>
       <!-- UPDATE -->
diff --git a/src/examples/Mini/ASTFunAppl.java b/src/examples/Mini/ASTFunAppl.java
index d5e9a475..95c04b37 100644
--- a/src/examples/Mini/ASTFunAppl.java
+++ b/src/examples/Mini/ASTFunAppl.java
@@ -25,6 +25,7 @@ import org.apache.bcel.generic.INVOKESTATIC;
 import org.apache.bcel.generic.InstructionList;
 import org.apache.bcel.generic.MethodGen;
 import org.apache.bcel.generic.Type;
+import org.apache.commons.lang3.ArrayUtils;
 
 /**
  */
@@ -72,7 +73,7 @@ public class ASTFunAppl extends ASTExpr {
             ASTFunDecl.pop();
             il.append(new INVOKESTATIC(cp.addMethodref(className, "_writeInt", "(I)I")));
         } else { // Normal function
-            final int size = exprs.length;
+            final int size = ArrayUtils.getLength(exprs);
             Type[] argv = null;
 
             if (exprs != null) {