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

FP in S3749 when spring class is not a singleton

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.5
    • Component/s: Rules
    • Labels:

      Description

      As explained by S3749, spring classes are singleton by default, but @Scope annotation can change this behavior. From the documentation:
      As a rule of thumb, you should use the prototype scope for all beans that are stateful
      In addition, you can define a custom scope, that could also change it.

      We should therefore report an issue only when the scope is known, and not "prototype".

      @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
      @Scope("prototype")
      @Scope(value = "prototype")
      @Scope("custom-scope")
      

      Note: S3750 already detect @Scope annotations.

      See: Spring scope documentation

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: