Permalink
Browse files

Make unsynchronized LoggerFactory field syncronized

Because the compiler or processor may reorder instructions, threads
are not guaranteed to see a completely initialized object if the
init function is called by two different threads.

Change-Id: I33342891fe098f84791bf8358e82f31a4bc99d92
Reviewed-on: http://review.couchbase.org/21152
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
  • Loading branch information...
mikewied committed Sep 26, 2012
1 parent 388fd0e commit d584446c647b89f0bb433fea43fbe983a709aee1
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/main/java/net/spy/memcached/compat/log/LoggerFactory.java
@@ -44,7 +44,7 @@
*/
public final class LoggerFactory extends Object {
- private static LoggerFactory instance = null;
+ private static volatile LoggerFactory instance = null;
private final ConcurrentMap<String, Logger> instances;
private Constructor<? extends Logger> instanceConstructor;

0 comments on commit d584446

Please sign in to comment.