Uploaded image for project: 'JBoss Log Manager'
  1. JBoss Log Manager
  2. LOGMGR-187

The ClassLoaderLogContextSelector check for the log context should return null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 2.1.0.Final
    • None
    • None
    • None

      The ClassLoaderLogContextSelector check for the registered LogContext returns defaultSelector.getLogContext() in the check() method and should return null.

      Previous Version
       private final PrivilegedAction<LogContext> logContextAction = new PrivilegedAction<LogContext>() {
          public LogContext run() {
              for (Class<?> caller : GATEWAY.getClassContext()) {
                  final ClassLoader classLoader = caller.getClassLoader();
                  final LogContext result = check(classLoader);
                  if (result != null) {
                      return result;
                  }
              }
              return defaultSelector.getLogContext();
          }
      
          private LogContext check(final ClassLoader classLoader) {
              if (classLoader != null && !logApiClassLoaders.contains(classLoader)) {
                  final LogContext context = contextMap.get(classLoader);
                  if (context != null) {
                      return context;
                  }
                  if (checkParentClassLoaders) {
                      return check(classLoader.getParent());
                  }
              }
              return null;
          }
      };
      
      Current Version
      private final PrivilegedAction<LogContext> logContextAction = new PrivilegedAction<LogContext>() {
          public LogContext run() {
              final Class<?> callingClass = JDKSpecific.findCallingClass(logApiClassLoaders);
              return callingClass == null ? defaultSelector.getLogContext() : check(callingClass.getClassLoader());
          }
      
          private LogContext check(final ClassLoader classLoader) {
              final LogContext context = contextMap.get(classLoader);
              if (context != null) {
                  return context;
              }
              final ClassLoader parent = classLoader.getParent();
              if (parent != null && checkParentClassLoaders && ! logApiClassLoaders.contains(parent)) {
                  return check(parent);
              }
              return defaultSelector.getLogContext();
          }
      };
      

      The new version only checks the first caller found, then returns the default. The older version checks the callers until it finds a non-null value finally returning the default if no callers were found with associated contexts.

            jperkins-rhn James Perkins
            jperkins-rhn James Perkins
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: