@Nullable in block() is not evaluated and leads to "Expression is allways true"

  • SonarQube Community Edition Version 7.9.4
  • SonarJava 6.3.2 (build 22818)
  • Rule S2589

block() function has @Nullable but is not taken in consideration and if condition leads to “Expression is allways true”

String value = WebClient.builder().build().get()
         .uri("http://localhost")
         .retrieve()
         .bodyToMono(String.class)
         .block();
if(value!=null){ //<-- This can be null
}

Example:
image

Hello @Francesc_Jorda and welcome to the community!

Supported annotations for this rule are listed here.
Note that we recently updated the list, it will be effective for SonarQube 8.6 and already on SonarCloud.

Can you provide us the fully qualified name of the @Nullable annotation which is not taken into consideration? If it is not already in the list, I would be happy to extend it.

Hi,

I’ve checked and is not in the list.
The one missing for us is:
reactor.util.annotation.Nullable

thank you!

Thanks for the update.

Ticket created: SONARJAVA-3586.

Best,
Quentin

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