False positive for "Null pointers should not be dereferenced" in case of ternary operators

Hi, I have a false positive for the “Null pointers should not be dereferenced” in case of ternary operators.
Sonarqube version 6.7.6 (build 38781)

As you can see from the screenshot at the beginning of the method i define my object “globalList” so that it can never be null using a ternary operator but it seems that it is not considered by Sonar.


You’re executing the getGlobalList method twice, There’s no guarantee that the second call will return the same value as the first call, therefore your globalList could be null even though you checked if getGlobalList returned null before.


Yep, you are right.
On my current code getGlobalList returns the same value if the input parameters are the same, but from an analysis point of view it is actually true that it could return different values for different calls.
Thanks a lot for your help