Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double checked locking on Log4JLogFactory.getInstance() #311

Closed
meg23 opened this issue Nov 13, 2014 · 2 comments
Closed

Double checked locking on Log4JLogFactory.getInstance() #311

meg23 opened this issue Nov 13, 2014 · 2 comments

Comments

@meg23
Copy link

meg23 commented Nov 13, 2014

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

@meg23
Copy link
Author

meg23 commented Nov 13, 2014

From d.bo...@gmail.com on July 31, 2013 10:23:11

Just not realised that volatile is in use, sry

@kwwall
Copy link
Contributor

kwwall commented Jan 10, 2016

This should be okay since singletonInstance in the Log4JLogFactory class is declared with the 'volatile' modifier. Closing the issue.

@kwwall kwwall closed this as completed Jan 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants