False positive: Java: NullPointerException could be thrown

SonarQube Version 8.5.1 (build 38104)

Null condition is checked in a ternary (elvis) operator.

 public void consumerError(ErrorMessage errorMessage) {
        String payload = (errorMessage.getOriginalMessage() != null && errorMessage.getOriginalMessage().getPayload() != null)
                ? errorMessage.getOriginalMessage().getPayload().toString()
                : errorMessage.getPayload().getMessage();
        LOGGER.error("Error receiving event with message: {}", payload, errorMessage.getPayload());

Hello @rodrigolopes and welcome to the SonarSource community!

You can have a look at this thread for a similar problem:

Hope this clarifies the situation.


1 Like

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