Double checked locking on Log4JLogFactory.getInstance()

Description

From d.bo...@gmail.com on July 31, 2013 13:15:30

There is a double checked locking error on Log4JLogFactory.getInstance().
This issue could result in returning a partially constructed object.

For more details see: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html You could synchronize the whole method or to avoid the overhead of synchronization, you could directly instantiate the object on the declaration line.

like:

private static final LogFactory singletonInstance = new Log4JLogFactory();

Original issue: http://code.google.com/p/owasp-esapi-java/issues/detail?id=305

Environment

None

Status

Assignee

Unassigned

Reporter

Max Gelman

Priority

Configure