Logger demandLogger ( String name , String resourceBundleName , Class < ? > caller ) { Logger result = getLogger ( name ) ; if ( result == null ) { // only allocate the new logger once Logger newLogger = new Logger ( name , resourceBundleName , caller ) ; do { if ( addLogger ( newLogger ) ) { // We successfully added the new Logger that we // created above so return it without refetching. return newLogger ; } // We didn't add the new Logger that we created above // because another thread added a Logger with the same // name after our null check above and before our call // to addLogger(). We have to refetch the Logger because // addLogger() returns a boolean instead of the Logger // reference itself. However, if the thread that created // the other Logger is not holding a strong reference to // the other Logger, then it is possible for the other // Logger to be GC'ed after we saw it in addLogger() and // before we can refetch it. If it has been GC'ed then // we'll just loop around and try again. result = getLogger ( name ) ; } while ( result == null ) ; } return result ; }
readConfiguration and other methods .