fusioncop / owasp-esapi-java

Automatically exported from code.google.com/p/owasp-esapi-java
Other
0 stars 0 forks source link

Double checked locking on Log4JLogFactory.getInstance() #305

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by d.bo...@gmail.com on 31 Jul 2013 at 5:15

GoogleCodeExporter commented 9 years ago
Just not realised that volatile is in use, sry

Original comment by d.bo...@gmail.com on 31 Jul 2013 at 5:23