-
Bug
-
Resolution: Done
-
Blocker
-
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.