You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by mb...@apache.org on 2023/01/09 07:08:08 UTC

[netbeans] branch master updated: fix NPE in RemoveUnnecessary class when case statement list is null.

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

mbien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 442b693bb5 fix NPE in RemoveUnnecessary class when case statement list is null.
     new 4b3794d0a6 Merge pull request #5179 from mbien/npe-fix-gh-5177
442b693bb5 is described below

commit 442b693bb556d0a02db0e4085843e9a5eeadf7dd
Author: Michael Bien <mb...@gmail.com>
AuthorDate: Mon Jan 2 21:08:59 2023 +0100

    fix NPE in RemoveUnnecessary class when case statement list is null.
---
 .../org/netbeans/modules/java/hints/control/RemoveUnnecessary.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java b/java/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
index b1c9a7dfcd..61604dbfdb 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
@@ -145,10 +145,13 @@ public class RemoveUnnecessary {
                 case CASE: {
                     if (tp.getParentPath().getLeaf().getKind() == Kind.SWITCH) {
                         List<? extends CaseTree> cases = ((SwitchTree) tp.getParentPath().getLeaf()).getCases();
-                        List<StatementTree> locStatements = new ArrayList<StatementTree>();
+                        List<StatementTree> locStatements = new ArrayList<>();
 
                         for (int i = cases.indexOf(tp.getLeaf()); i < cases.size(); i++) {
-                            locStatements.addAll(cases.get(i).getStatements());
+                            List<? extends StatementTree> list = cases.get(i).getStatements();
+                            if (list != null) {
+                                locStatements.addAll(list);
+                            }
                         }
 
                         statements = locStatements;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists