[jboss-jira] [JBoss JIRA] (LOGMGR-187) The ClassLoaderLogContextSelector check for the log context should return null

James Perkins (JIRA) issues at jboss.org
Mon Dec 18 16:25:00 EST 2017


     [ https://issues.jboss.org/browse/LOGMGR-187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Perkins updated LOGMGR-187:
---------------------------------
    Priority: Blocker  (was: Major)


> The ClassLoaderLogContextSelector check for the log context should return null
> ------------------------------------------------------------------------------
>
>                 Key: LOGMGR-187
>                 URL: https://issues.jboss.org/browse/LOGMGR-187
>             Project: JBoss Log Manager
>          Issue Type: Bug
>            Reporter: James Perkins
>            Assignee: James Perkins
>            Priority: Blocker
>             Fix For: 2.1.0.Alpha6
>
>
> The {{ClassLoaderLogContextSelector}} check for the registered {{LogContext}} returns {{defaultSelector.getLogContext()}} in the {{check()}} method and should return {{null}}.
> {code:title=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;
>     }
> };
> {code}
> {code:title=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();
>     }
> };
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list