Hi David, Thanks a lot for your feedback!
On 9/4/13 11:36 PM, David M. Lloyd wrote:
As far as calling initialization ("ensureLogManagerInitialized()"), it's a shame that checking for a one-time action has to run through a synchronization block every time. Maybe a "lazy holder" class would be more appropriate here, especially given that the point seems to be to produce the RootLogger() instance which doubles as the indicator that initialization was done.
The point here is that we don't want a thread to be able to get at an half initialized LogManager, for instance, one in which the root logger would have been added but not the global logger. This could lead to all kind of race conditions. So I think RootLogger can't really be used as a marker here. I'll double check that however. You wouldn't believe all the exceptions that were raised when I started working naively on this issue ;-)
I think I'd prefer to stay away from static initializers for this piece of code. I'd propose to use a volatile boolean to mark when initialization is truly finished. This way there would be no need to enter the synchronized block once LogManager has
finished initializing. I'll send a new webrev.
There's a grammatical error in the comment at line 1547 of LogManager.java: "We do not the protected Logger <...>".
Oh. Thanks for catching that! best regards, -- daniel