Sonar ignores that instanceof checks for null

Sonar perceives this as a bug, but instanceof already checks for null and will return false in that case.


The analyzer doesn’t “know” if the two exception.getRootCause() calls will return the same value or not. If somehow these calls return different values, the code will fail.

Just to be safe, you could assign the result of exception.getRootCause() to a variable and use it instead of repeating the method call.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.