The Javadoc for LogManager.addLogger() "The application should retain its own reference to the Logger object to avoid it being garbage collected. The LogManager may only retain a weak reference." is a perfectly good justification to keep an outside reference, thanks.
You might actually be running up against an implementation detail difference between different JDKs, or even different versions of the same JDK, because the javadoc allows the implementation to decide whether to hold a strong or weak reference. On Tue, Jul 20, 2010 at 3:04 PM, Unnur Gretarsdottir <[email protected]>wrote: > It does do that - and I can't see where/how it's using a weak reference > to store the loggers (it looks to me like they use a regular > java.util.Hashtable), but the comments in the implementation of LogManager > class file that I see when debugging using Eclipse do say that the user has > to keep a reference to the logger or it may be garbage collected. > > I spent a long time debugging this yesterday, and was able to > consistently reproduce this - if I hit refresh in Dev mode, the Root Logger > gets nulled out about every 1/5 - 1/20 times in the google project for the > team that reported this. If it happens, it always happens in the same place > (at least in this particular project), but I couldn't see any reasonable > place that it could be happening - at least not in any code that I can step > through in the debugger (although admittedly, my ability to clearly step > through some of the depths of the JRE code in Eclipse is not very good). > > When I made this change, I was unable to reproduce the problem, even > though I hit refresh tens of times. I wish I had a more concrete > justification, but in the end, it was late, and this was a fix that at least > appeared to fix the problem, and was somewhat justified by the comments in > the JRE class, if not the code that I saw. I pinged the team that initially > saw the issue, and I've asked them to also try out the fix and confirm that > it works. Ugh... > > - Unnur > > > > On Tue, Jul 20, 2010 at 11:41 AM, <[email protected]> wrote: > >> Just out of curiosity, why is this actually necessary? >> >> Shouldn't DevModeLogManager -> clientLogManager -> loggers -> >> Map<String, Logger>? >> >> >> http://gwt-code-reviews.appspot.com/667802/show >> > > -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
