jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
changeset 34774 03b4e6dc367b
parent 33875 c1c71107d45f
child 34882 ce2a8ec851c1
equal deleted inserted replaced
34764:f9bcdce2df26 34774:03b4e6dc367b
   324         }
   324         }
   325 
   325 
   326     }
   326     }
   327 
   327 
   328     // Do not expose this outside of this package.
   328     // Do not expose this outside of this package.
   329     private static volatile LoggerFinder provider = null;
   329     private static volatile LoggerFinder provider;
   330     private static LoggerFinder accessLoggerFinder() {
   330     private static LoggerFinder accessLoggerFinder() {
   331         if (provider == null) {
   331         LoggerFinder prov = provider;
       
   332         if (prov == null) {
   332             // no need to lock: it doesn't matter if we call
   333             // no need to lock: it doesn't matter if we call
   333             // getLoggerFinder() twice - since LoggerFinder already caches
   334             // getLoggerFinder() twice - since LoggerFinder already caches
   334             // the result.
   335             // the result.
   335             // This is just an optimization to avoid the cost of calling
   336             // This is just an optimization to avoid the cost of calling
   336             // doPrivileged every time.
   337             // doPrivileged every time.
   337             final SecurityManager sm = System.getSecurityManager();
   338             final SecurityManager sm = System.getSecurityManager();
   338             provider = sm == null ? LoggerFinder.getLoggerFinder() :
   339             prov = sm == null ? LoggerFinder.getLoggerFinder() :
   339                 AccessController.doPrivileged(
   340                 AccessController.doPrivileged(
   340                         (PrivilegedAction<LoggerFinder>)LoggerFinder::getLoggerFinder);
   341                         (PrivilegedAction<LoggerFinder>)LoggerFinder::getLoggerFinder);
   341         }
   342             provider = prov;
   342         return provider;
   343         }
       
   344         return prov;
   343     }
   345     }
   344 
   346 
   345     // Avoid using lambda here as lazy loggers could be created early
   347     // Avoid using lambda here as lazy loggers could be created early
   346     // in the bootstrap sequence...
   348     // in the bootstrap sequence...
   347     private static final BiFunction<String, Class<?>, Logger> loggerSupplier =
   349     private static final BiFunction<String, Class<?>, Logger> loggerSupplier =