-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code
Milestone
Description
The ClassLoaderContextSelector#locateContext currently implements the following logic:
Lines 189 to 221 in f05864d
| if (ref == null) { | |
| if (configLocation == null) { | |
| ClassLoader parent = loader.getParent(); | |
| while (parent != null) { | |
| ref = CONTEXT_MAP.get(toContextMapKey(parent)); | |
| if (ref != null) { | |
| final WeakReference<LoggerContext> r = ref.get(); | |
| final LoggerContext ctx = r.get(); | |
| if (ctx != null) { | |
| return ctx; | |
| } | |
| } | |
| parent = parent.getParent(); | |
| /* In Tomcat 6 the parent of the JSP classloader is the webapp classloader which would be | |
| configured by the WebAppContextListener. The WebAppClassLoader is also the ThreadContextClassLoader. | |
| In JBoss 5 the parent of the JSP ClassLoader is the WebAppClassLoader which is also the | |
| ThreadContextClassLoader. However, the parent of the WebAppClassLoader is the ClassLoader | |
| that is configured by the WebAppContextListener. | |
| ClassLoader threadLoader = null; | |
| try { | |
| threadLoader = Thread.currentThread().getContextClassLoader(); | |
| } catch (Exception ex) { | |
| // Ignore SecurityException | |
| } | |
| if (threadLoader != null && threadLoader == parent) { | |
| break; | |
| } else { | |
| parent = parent.getParent(); | |
| } */ | |
| } | |
| } |
If the initial ContextSelector#getContext call does not provide a configLocation parameter and there is already a logger context associated to an ancestor of the loader classloader, no new context is created and the logger context of the ancestor is returned.
While this might be a feature to minimize the number of logger contexts, IMHO it should be optional and the default behavior should be to create a different logger context per classloader.
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code
Type
Projects
Status
To triage