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());
}
Quentin
(Quentin Jaquier)
January 7, 2021, 3:56pm
2
Hello @rodrigolopes and welcome to the SonarSource community!
You can have a look at this thread for a similar problem:
We recently upgraded from 8.4.1 to 8.5.1. After this upgrade we have been hit with dozens of false positives surrounding null checks, such as the one seen in this screenshot:
[image]
The line immediately before the issue shows a null check for agenda.getBody(), so it cannot be null at the time getJobs() is called.
I am aware that some are caused by SonarQube not being able to see null checks that happen in called methods, but this clearly has the null check in the same expression.
Has anyo…
Hope this clarifies the situation.
Best,
Quentin