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

FP in S2226 for non final Servlet fields initialized in init() method without parameters

    Details

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

      Description

      Instance fields for Servlets should be either final or static. According to the Servlet should be a singleton object per path, so its fields can be accessed from different threads. 

      On the other hand, to initialize fields depending on Servlet Configuration method init()
      should be used. So fields initialized in init() method can't be marked final.

      So we can accept non-final instance fields, if they are set in init() method only.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                margarita.nedzelska Margarita Nedzelska
                Reporter:
                margarita.nedzelska Margarita Nedzelska
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: