Affects PMD Version:
5.4.2
Rule:
SingletonClassReturningNewInstance
Description:
The rule incorrectly indicates that the code sample always returns a new instance:
getInstance method always creates a new object and hence does not comply to Singleton Design Pattern behaviour.
Code Sample demonstrating the issue:
public final class Foo { private static volatile Foo myFoo; public static Foo getInstance() { Foo instance = myFoo; if (instance == null) { synchronized (Foo .class) { instance = myFoo; if (instance == null) { myFoo= instance = new Foo(); } } } return instance; } }
Running PMD through: Gradle (SonarQube)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4