-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[java] NPE in type inference #5190
Copy link
Copy link
Closed
Labels
a:bugPMD crashes or fails to analyse a file.PMD crashes or fails to analyse a file.in:type-resolutionAffects the type resolution codeAffects the type resolution code
Milestone
Description
Affects PMD Version:
7.5.0 (this didn't happen with version 7.4.0 and under)
Rule:
No rules as its failing to parse the code
Description:
[INFO] --- pmd:3.25.0:pmd (pmd) @ uk-multi-policy-group-service ---
17:53:18 [INFO] PMD version: 7.5.0
17:53:27 [ERROR] PMD processing errors:
17:53:27 [ERROR] /home/teamcity/work/402506fd6a30bd90/uk-multi-policy-group-service/src/test/java/com/marshmallow/uk_multi_policy_group/persistence/policy_group_numbers/PolicyGroupNumberGeneratorStoreTest.java: ContextedRuntimeException: java.lang.NullPointerException: Cannot invoke "net.sourceforge.pmd.lang.java.types.JTypeMirror.equals(Object)" because "asSuperOfS" is null
17:53:27 Exception Context:
17:53:27 [1:Resolving type of=!debug only! [MethodCall:174:16]Optional.ofNullable(
17:53:27 Iterables.getOnlyElement(queryForKey(key), null)
17:53:27 )]
17:53:27 [2:Location=!debug only! /home/teamcity/work/402506fd6a30bd90/uk-multi-policy-group-service/src/test/java/com/marshmallow/uk_multi_policy_group/persistence/policy_group_numbers/PolicyGroupNumberGeneratorStoreTest.java:174:16]
17:53:27 ---------------------------------
Code Sample demonstrating the issue:
private Optional<Map<String, AttributeValue>> loadForKey(final String key) {
return Optional.ofNullable(
Iterables.getOnlyElement(queryForKey(key), null)
);
}Expected outcome:
PMD reports a violation at line ..., but that's wrong. That's a false positive.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Maven (v3.5.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a:bugPMD crashes or fails to analyse a file.PMD crashes or fails to analyse a file.in:type-resolutionAffects the type resolution codeAffects the type resolution code