tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/juli/src/java/org/apache/juli ClassLoaderLogManager.java
Date Fri, 04 Mar 2005 14:59:19 GMT
remm        2005/03/04 06:59:19

  Modified:    juli/src/java/org/apache/juli ClassLoaderLogManager.java
  Log:
  - Fix NPEs when context CL is null, which occurs in JNI mode (cool feature ...).
  
  Revision  Changes    Path
  1.6       +28 -20    jakarta-tomcat-connectors/juli/src/java/org/apache/juli/ClassLoaderLogManager.java
  
  Index: ClassLoaderLogManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/juli/src/java/org/apache/juli/ClassLoaderLogManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ClassLoaderLogManager.java	3 Mar 2005 13:34:17 -0000	1.5
  +++ ClassLoaderLogManager.java	4 Mar 2005 14:59:19 -0000	1.6
  @@ -40,20 +40,6 @@
    */
   public final class ClassLoaderLogManager extends LogManager {
   
  -    private static void doSetParentLogger(final Logger logger,
  -            final Logger parent) {
  -        if (System.getSecurityManager() != null) {
  -            AccessController.doPrivileged(new PrivilegedAction() {
  -                public Object run() {
  -                    logger.setParent(parent);
  -                    return null;
  -                }
  -            });
  -        } else {
  -            logger.setParent(parent);
  -        }
  -    }
  -
       private final Map classLoaderLoggers = new WeakHashMap();
   
       private Logger rootLogger;
  @@ -86,6 +72,9 @@
           }
           ClassLoader classLoader = 
               Thread.currentThread().getContextClassLoader();
  +        if (classLoader == null) {
  +            return super.addLogger(logger);
  +        }
           ClassLoaderLogInfo info = getClassLoaderInfo(classLoader);
           if (info.loggers.containsKey(loggerName)) {
               return false;
  @@ -196,6 +185,9 @@
           }
           final ClassLoader classLoader = Thread.currentThread()
                   .getContextClassLoader();
  +        if (classLoader == null) {
  +            return super.getLogger(name);
  +        }
           final Map loggers = getClassLoaderInfo(classLoader).loggers;
           return (Logger) loggers.get(name);
       }
  @@ -208,6 +200,9 @@
           }
           final ClassLoader classLoader = Thread.currentThread()
                   .getContextClassLoader();
  +        if (classLoader == null) {
  +            return super.getLoggerNames();
  +        }
           final Map loggers = getClassLoaderInfo(classLoader).loggers;
           return Collections.enumeration(loggers.keySet());
       }
  @@ -218,12 +213,15 @@
        * context.
        */    
       public String getProperty(String name) {
  +        final ClassLoader classLoader = Thread.currentThread()
  +            .getContextClassLoader();
  +        if (classLoader == null) {
  +            return super.getProperty(name);
  +        }
           String prefix = (String) this.prefix.get();
           if (prefix != null) {
               name = prefix + name;
           }
  -        final ClassLoader classLoader = Thread.currentThread()
  -                .getContextClassLoader();
           ClassLoaderLogInfo info = getClassLoaderInfo(classLoader);
           String result = info.props.getProperty(name);
           // If the property was not found, and the current classloader had no 
  @@ -264,10 +262,6 @@
       
       private ClassLoaderLogInfo getClassLoaderInfo(final ClassLoader classLoader) {
           
  -        if (classLoader == null) {
  -            return null;
  -        }
  -        
           ClassLoaderLogInfo info = (ClassLoaderLogInfo) classLoaderLoggers
                   .get(classLoader);
           if (info == null) {
  @@ -365,6 +359,20 @@
           return info;
       }
   
  +    private static void doSetParentLogger(final Logger logger,
  +            final Logger parent) {
  +        if (System.getSecurityManager() != null) {
  +            AccessController.doPrivileged(new PrivilegedAction() {
  +                public Object run() {
  +                    logger.setParent(parent);
  +                    return null;
  +                }
  +            });
  +        } else {
  +            logger.setParent(parent);
  +        }
  +    }
  +
       private static final class LogNode {
           Logger logger;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message