ER-212 Statefull Singleton could cause problems in an environment of EJB, Clustering, or Load Balancing Architecture. Make sure that all you class and instance variables are final. This inspector found non-final variable(s), beside the variable referenzing the singleton.

Severity2
Enabledyes
Waivable
Violation
         public class Singleton {
       private static Singleton instance;
       private String statefull; 
       
       private Singleton() {
           }
   
       public static synchronized Singleton  getInstance() {
           if (instance == null) {
                instance = new Singleton();
            }
            return instance;
       }
   }
   
      
Fix
            public class Singleton {
       private static Singleton instance;
       private final String statefull; 
       
       private Singleton() {
           }
   
       public static synchronized Singleton  getInstance() {
           if (instance == null) {
                instance = new Singleton();
            }
            return instance;
       }
   }]
                
         


Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.