Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Parasoft Jtest 2020.2

...

Using improper forms of the Singleton design pattern may lead to creation of multiple instances of the singleton and violate the expected contract of the class.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MSC07-J

Low

Unlikely

Medium

P2

L3

Automated Detection

Tool
Version
Checker
Description
The Checker Framework

Include Page
The Checker Framework_V
The Checker Framework_V

Linear CheckerControl aliasing and prevent re-use (see Chapter 19)
Coverity7.5

SINGLETON_RACE
UNSAFE_LAZY_INIT
FB.LI_LAZY_INIT_UPDATE_STATIC
FB.LI_LAZY_INIT_STATIC

Implemented
Parasoft Jtest9.5TRS.ILI
Implemented
Make lazy initializations thread-safe

Related Guidelines

MITRE CWE

CWE-543, Use of Singleton Pattern without Synchronization in a Multithreaded Context

Bibliography

[Bloch 2008]

Item 3, "Enforce the Singleton Property with a Private Constructor or an enum Type"
Item 77, "For Instance Control, Prefer enum Types to readResolve"

[Daconta 2003]

Item 15, "Avoiding Singleton Pitfalls"

[Darwin 2004]

Section 9.10, "Enforcing the Singleton Pattern"

[Fox 2001]

When Is a Singleton Not a Singleton? 

[Gamma 1995]

Singleton

[Grand 2002]

Chapter 5, "Creational Patterns," section "Singleton"

[JLS 2015]

Chapter 17, "Threads and Locks"

...


...