Nullable not detected for Java records when ParametersAreNonnullByDefault is set on declaration

  • Operating system: Ubuntu 24.04
  • SonarLint plugin version: 10.14.0.80203
  • IntelliJ version: IntelliJ IDEA 2024.3.1 (Ultimate Edition)
  • Programming language you’re coding in: Java 21
  • Is connected mode used: No

And a thorough description of the problem / question:
Rule java:S4449 is triggered for a nullable parameter on a record while the Nullable annotation exists.
When you try to pass a nullable value for parameter paraTwo, you still get a warning for this rule.

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault

@ParametersAreNonnullByDefault
public record SomeRecord(SomeClass paraOne, @Nullable SomeClass paraTwo) {
}

Hey there.

Thanks for the report. It’s actually already being tracked at SONARJAVA-4500. I’ve attached this thread as an external link on that ticket.

1 Like

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