Null Pointer not detected

scanner
java

(Frogier) #1

Basic Information :

  • versions : 6.7.6.38781
  • error observed : Null Pointer not detected
  • steps to reproduce : Nothing to report
  • potential workaround : Nothing to report

Hi!

I have a bug with Sonar.
During an Java analysis, Sonar did not detect a null pointer exception on this code :

 public MyClass(MyObject o) {
               
        if(o.getGlobalStatus() != null && o.getSpecificStatus().getStatus() != null) {
            this.nameStatus = o.getGlobalStatus().getStatus().getName();
        }

}

Indeed, it is possible to have a null pointer exception on the call to getStatus() if getSpecificStatus() return null.

You can easily imagine that the mistake is that we want to put getGlobalStatus() instead of getSpecificStatus(). I believe that Sonar reflected as we did during the analysis and did not see our mistake.

Sorry for my english

Have a good day