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

[netbeans] branch delivery updated: fixed NPE in NBJavacTrees#getElement when path is null.

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

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


The following commit(s) were added to refs/heads/delivery by this push:
     new 0be57b9c1d9 fixed NPE in NBJavacTrees#getElement when path is null.
     new 366e0deac10 Merge pull request #5346 from mbien/npe-5202
0be57b9c1d9 is described below

commit 0be57b9c1d97f5c1a52f7c20d812ac47f1328339
Author: Michael Bien <mb...@gmail.com>
AuthorDate: Mon Jan 23 03:28:21 2023 +0100

    fixed NPE in NBJavacTrees#getElement when path is null.
---
 .../java/hints/jdk/mapreduce/PreconditionsChecker.java       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java b/java/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
index c314c55ccf7..02196f3f91f 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
@@ -223,11 +223,15 @@ public class PreconditionsChecker {
         }
 
         private boolean isLocalVariable(IdentifierTree id, Trees trees) {
-            Element el = trees.getElement(TreePath.getPath(treePath, id));
-            if (el != null) {
-                return el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER;
+            TreePath path = TreePath.getPath(treePath, id);
+            if (path == null) {
+                return false;
             }
-            return false;
+            Element el = trees.getElement(path);
+            if (el == null) {
+                return false;
+            }
+            return el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER;
         }
     }
 


---------------------------------------------------------------------
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