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.
- relates to
-
RSPEC-2226 Servlets should not have mutable instance fields
- Active
- links to