squid:S2259 : A "NullPointerException" could be thrown; "dc" is nullable here. While "dc" is checked as not null

java

(Franck Biellmann) #1

Hello.

We have a false positive with the " Null pointers should not be dereferenced -squid:S2259" rule :
We have a “NullPointerException” false positive for which we do not know how to solve it.
In the code, we check the not nullity with java.util.Objects.nonNull().
But even with this, the concerned object it tagged as a possible NullPointerException problem.

I have checked on multiple posts and googled it; It seemed that “crosschecked referenced issues” had been fixed since sonarqube 6.1; But not for this case.
Can you please help?

  • Version of Sonarqube used : 7.3.0.15553
  • version of SonarJava used : 5.7 (build 15470)

Screenshot of the issue :

Zoom on the code :

import java.util.Objects;
.....
.....
if ( Objects.nonNull( dc ) && Objects.nonNull( dc.getDate() ) ) {
   headers.put( MediacentricHeaders.Metadata.PUBLICATION_DATE, DateHelper.format( dc.getDate(), DateHelper.W3C_FORMATTER ) );
    LOGGER.debug( "dc:date found : {} ", dc.getDate() );
 }

Thank you!
Franck;


(Franck Biellmann) #2

Hello.

This subject does interest nobody?


(Franck Biellmann) #3

Last try of update…


(Franck Biellmann) #5

Hello.

Really no chance to get an update?