jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
changeset 32035 073a449c007d
parent 31150 2aa1d300cd75
child 32037 ab4526f4ac10
equal deleted inserted replaced
32034:05676cfd40b5 32035:073a449c007d
   351         // notice that initializationDone is now true and return.
   351         // notice that initializationDone is now true and return.
   352         // Otherwise - we have come here first! We will acquire the monitor,
   352         // Otherwise - we have come here first! We will acquire the monitor,
   353         // see that initializationDone is still false, and perform the
   353         // see that initializationDone is still false, and perform the
   354         // initialization.
   354         // initialization.
   355         //
   355         //
   356         synchronized(this) {
   356         configurationLock.lock();
       
   357         try {
   357             // If initializedCalled is true it means that we're already in
   358             // If initializedCalled is true it means that we're already in
   358             // the process of initializing the LogManager in this thread.
   359             // the process of initializing the LogManager in this thread.
   359             // There has been a recursive call to ensureLogManagerInitialized().
   360             // There has been a recursive call to ensureLogManagerInitialized().
   360             final boolean isRecursiveInitialization = (initializedCalled == true);
   361             final boolean isRecursiveInitialization = (initializedCalled == true);
   361 
   362 
   407                     }
   408                     }
   408                 });
   409                 });
   409             } finally {
   410             } finally {
   410                 initializationDone = true;
   411                 initializationDone = true;
   411             }
   412             }
       
   413         } finally {
       
   414             configurationLock.unlock();
   412         }
   415         }
   413     }
   416     }
   414 
   417 
   415     /**
   418     /**
   416      * Returns the global LogManager object.
   419      * Returns the global LogManager object.
   421             manager.ensureLogManagerInitialized();
   424             manager.ensureLogManagerInitialized();
   422         }
   425         }
   423         return manager;
   426         return manager;
   424     }
   427     }
   425 
   428 
   426     private void readPrimordialConfiguration() {
   429     private void readPrimordialConfiguration() { // must be called while holding configurationLock
   427         if (!readPrimordialConfiguration) {
   430         if (!readPrimordialConfiguration) {
   428             synchronized (this) {
   431             // If System.in/out/err are null, it's a good
   429                 if (!readPrimordialConfiguration) {
   432             // indication that we're still in the
   430                     // If System.in/out/err are null, it's a good
   433             // bootstrapping phase
   431                     // indication that we're still in the
   434             if (System.out == null) {
   432                     // bootstrapping phase
   435                 return;
   433                     if (System.out == null) {
   436             }
   434                         return;
   437             readPrimordialConfiguration = true;
   435                     }
   438             try {
   436                     readPrimordialConfiguration = true;
   439                 readConfiguration();
   437 
   440 
   438                     try {
   441                 // Platform loggers begin to delegate to java.util.logging.Logger
   439                         AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
   442                 sun.util.logging.PlatformLogger.redirectPlatformLoggers();
   440                                 @Override
   443             } catch (Exception ex) {
   441                                 public Void run() throws Exception {
   444                 assert false : "Exception raised while reading logging configuration: " + ex;
   442                                     readConfiguration();
       
   443 
       
   444                                     // Platform loggers begin to delegate to java.util.logging.Logger
       
   445                                     sun.util.logging.PlatformLogger.redirectPlatformLoggers();
       
   446                                     return null;
       
   447                                 }
       
   448                             });
       
   449                     } catch (Exception ex) {
       
   450                         assert false : "Exception raised while reading logging configuration: " + ex;
       
   451                     }
       
   452                 }
       
   453             }
   445             }
   454         }
   446         }
   455     }
   447     }
   456 
   448 
   457     // LoggerContext maps from AppContext
   449     // LoggerContext maps from AppContext