sithmein
(Thorsten Meinl)
June 16, 2025, 12:14pm
1
The following snippet raises a false positive of java:S2259
:
void foo (Map<String, @Nullable String> map) {
map.size(); // "A "NullPointerException" could be thrown; "map" is nullable here.
}
Sonar seems to think that the complete map can be null
when only it’s values can be null
.
Screenshot of a real-world example:
sithmein
(Thorsten Meinl)
June 16, 2025, 12:16pm
2
It seems to affects any generic type where the type parameter allows for null
values:
Hello @sithmein
Thanks a lot for providing this feedback.
We are reviewing the exact code for the rule (there has been some changes in its code lately), and most probably we will create a ticket to tackle this FP.
I will keep you updated.
Hello @sithmein ,
Thanks again for your feedback and sorry for the late reply. I’ve created a ticket in our internal backlog to fix the reported FP.
Will come back here to notify when the fix lands in SonarQube Cloud.