Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3447

FN on S2259 when a method is annotated with spring's annotation @Nullable

    Details

    • Type: False Negative
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.7, 6.X.SE
    • Component/s: Symbolic Execution
    • Labels:
      None

      Description

      Spring's @org.springframework.lang.Nullable annotation is not handled properly when annotating (the return value of) a method, leading to FN in implementation of RSPEC-2259.

      Looking at the declaration of Spring @Nullable, it uses the meta-annotation from javax @Nonnull as following:

      package org.springframework.lang;
      ...
      javax.annotation.Nonnull(when = When.MAYBE)
      @interface Nullable {
        ...
      }
      

      This is exactly the same way that the javax @CheckForNull annotation is defined, and we should, therefore, handle both annotations the same way.

      Contrarily to javax's @Nullable (using @Nonnull(when = When.UNKNOWN)), the Spring's @Nullable implies that a null check is mandatory.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                michael.gumowski Michael Gumowski
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: