mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 23:55:52 +00:00
Reverting 4de81f1eb3.
Max Spring discovered a stack overflow in http://jenkins.361315.n4.nabble.com/channel-example-and-plugin-classes-gives-ClassNotFoundException-td3756092.html that pointed this call into thread context classloader (TCL) as the culprit. Independently, Paul Sandoz discovered the same issue in our products. If TCL is another classloader that delegates to UberClassLoader (UCL), this code causes infinite recursion.
And moreover, given the goal of UCL, it seems wrong that this class is changing behaviour based on contextual information like TCL.
In looking at 4de81f1eb3, the change was introduced to make sure XStream unmarshalling invoked from Plugin.start() would see the classes in that plugin. This was an issue back then when plugins are prepared and loaded one by one, as UCL didn't have visibility into plugins being prepared. But in the current Jenkins, classloaders for all the plugins are prepared, before any plugin gets started, so by the time Plugin.start() runs, UCL is fully functioning.
Therefore, there's no need to consult TCL for the purpose of resolving its own classes. I could have also removed the code that sets TCL, but because some libraries often depend on TCL and doesn't properly look at caller class, I'm leaving it in, even though it's generally a bad practice to rely on TCL in multi-classloader apps like Jenkins
This commit is contained in:
1 parent
bcdff8c55b
commit
f322503d3a
2 files changed
+2
-12
No files matched your search
@@ -607,16 +607,6 @@ public abstract class PluginManager extends AbstractModelObject {
|
||||
else generatedClasses.remove(name,wc);
|
||||
}
|
||||
|
||||
// first, use the context classloader so that plugins that are loading
|
||||
// can use its own classloader first.
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if(cl!=null && cl!=this)
|
||||
try {
|
||||
return cl.loadClass(name);
|
||||
} catch(ClassNotFoundException e) {
|
||||
// not found. try next
|
||||
}
|
||||
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
try {
|
||||
return p.classLoader.loadClass(name);
|
||||
|
||||
Reference in new issue
Block a user