SONARJAVA-2785 is now marked as fixed for version 5.5 but I can still reproduce the original problem with SonarJava 5.6 with the exact same reproducer as in the original post.
I seem to also be still seeing this problem in SonarJava 5.6 on SonarQube 6.7.5 LTS.
The code I have is calling Springâs Environment.getProperty which is inherited from AbstractEnvironment.getProperty which implements PropertyResolver.getProperty; both are annotated with @Nullable from org.springframework.lang.
The SonarQube UI is highlighting null != healthUrl as always evaluating to true.
The steps itâs giving are:
âgetProperty()â can return not null
âgetHealthUrl()â returns not null.
Implies âhealthUrlâ is not null.
Expression is always true.
The weird this is that itâs changing âcan return not nullâ into âreturns not nullâ. Yes, it can return not null, but it can also return null, and in that case this expression evaluates to false. Why is it missing that?
Yes the problem still exits, I can reproduce it in a small spring project. The support of spring annotations implemented in SONARJAVA-2785 was not tested without jsr305 binary and has a bug in this case.
I have created the bug fix ticket SONARJAVA-2864 to fix this problem in the next version.