You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/07/24 11:48:52 UTC
[GitHub] geertjanw closed pull request #635: [NetBeans-1019]False positive
of "Null Pointer Dereference" when passing a lambda with a null possible
result to a non-null argument
geertjanw closed pull request #635: [NetBeans-1019]False positive of "Null Pointer Dereference" when passing a lambda with a null possible result to a non-null argument
URL: https://github.com/apache/incubator-netbeans/pull/635
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/NPECheck.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/NPECheck.java
index bc5b0e516..4c2e8b774 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/NPECheck.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/NPECheck.java
@@ -625,7 +625,7 @@ public State scan(Tree tree, Void p) {
TypeMirror currentType = tree != null ? info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), tree)) : null;
- if (currentType != null && currentType.getKind().isPrimitive()) {
+ if ((tree != null && tree.getKind() == Kind.LAMBDA_EXPRESSION) || (currentType != null && currentType.getKind().isPrimitive())) {
r = State.NOT_NULL;
}
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/NPECheckTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/NPECheckTest.java
index fc6717f56..87f630807 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/NPECheckTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/bugs/NPECheckTest.java
@@ -273,6 +273,23 @@ public void testParameter3() throws Exception {
"0:62-0:65:verifier:ERR_POSSIBLENULL_TO_NON_NULL_ARG");
}
+ public void testParameter4() throws Exception {
+ HintTest.create()
+ .sourceLevel("8")
+ .input("test/Test.java",
+ "package test; \n" +
+ "import java.util.function.Function; \n" +
+ "class Test { \n" +
+ " private void func(@NotNull Function<Object, Object> func){} \n" +
+ " @CheckForNull private Object foo(){ return null;} \n" +
+ " private void bar(){func((item)->foo());} \n" +
+ " private @CheckForNull String t() { return null;}} \n" +
+ " @interface NotNull {} \n" +
+ " @interface CheckForNull {}")
+ .run(NPECheck.class)
+ .assertNotContainsWarnings("ERR_POSSIBLENULL_TO_NON_NULL_ARG");
+ }
+
public void testNoMultipleReports1() throws Exception {
performAnalysisTest("test/Test.java",
"package test;\n" +
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists