[
https://issues.apache.org/jira/browse/LOG4J2-2754?focusedWorklogId=365070&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-365070
]
ASF GitHub Bot logged work on LOG4J2-2754:
------------------------------------------
Author: ASF GitHub Bot
Created on: 31/Dec/19 20:12
Start Date: 31/Dec/19 20:12
Worklog Time Spent: 10m
Work Description: carterkozak commented on pull request #328:
LOG4J2-2754: LoaderUtil.getClassLoaders may discover additional loaders
URL: https://github.com/apache/logging-log4j2/pull/328#discussion_r362274587
##########
File path:
log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java
##########
@@ -106,30 +104,31 @@ public ClassLoader run() {
}
public static ClassLoader[] getClassLoaders() {
- final List<ClassLoader> classLoaders = new ArrayList<>();
+ final Collection<ClassLoader> classLoaders = new LinkedHashSet<>();
final ClassLoader tcl = getThreadContextClassLoader();
- classLoaders.add(tcl);
- // Some implementations may use null to represent the bootstrap class
loader.
- final ClassLoader current = LoaderUtil.class.getClassLoader();
- if (current != null && current != tcl) {
- classLoaders.add(current);
- final ClassLoader parent = current.getParent();
- while (parent != null && !classLoaders.contains(parent)) {
- classLoaders.add(parent);
Review comment:
This loop failed to modify the condition
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 365070)
Time Spent: 20m (was: 10m)
> LoaderUtil.getClassLoaders fails to update loop state
> -----------------------------------------------------
>
> Key: LOG4J2-2754
> URL: https://issues.apache.org/jira/browse/LOG4J2-2754
> Project: Log4j 2
> Issue Type: Bug
> Affects Versions: 2.13.0
> Reporter: Carter Kozak
> Assignee: Carter Kozak
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Same problem as LOG4J2-2104, but for final 'ClassLoader current =
> LoaderUtil.class.getClassLoader();'
> The while loop acts as a simple conditional (unless a classloader is defined
> with an incorrect 'equals' method, then it loops infinitely -- I've not seen
> this behavior in practice though).
> It appears that getThreadContextClassLoader can return a null ClassLoader,
> which ends up in the getClassLoaders result erroneously.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)