| Severity | 2 |
|---|---|
| Enabled | yes |
| 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;
}
}]
|