mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-29 04:25:23 +00:00
fixed a bug where XStream activity in plugins wasn't able to resolve classes.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1131 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
54db1b536f
commit
4de81f1eb3
2 files changed
+46
-28
No files matched your search
@@ -171,37 +171,45 @@ public final class PluginWrapper {
|
||||
throw new IOException("Plugin installation failed. No 'Plugin-Class' entry in the manifest of "+archive);
|
||||
}
|
||||
|
||||
// override the context classloader so that XStream activity in plugin.start()
|
||||
// will be able to resolve classes in this plugin
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
try {
|
||||
Class clazz = classLoader.loadClass(className);
|
||||
Object plugin = clazz.newInstance();
|
||||
if(!(plugin instanceof Plugin)) {
|
||||
throw new IOException(className+" doesn't extend from hudson.Plugin");
|
||||
try {
|
||||
Class clazz = classLoader.loadClass(className);
|
||||
Object plugin = clazz.newInstance();
|
||||
if(!(plugin instanceof Plugin)) {
|
||||
throw new IOException(className+" doesn't extend from hudson.Plugin");
|
||||
}
|
||||
this.plugin = (Plugin)plugin;
|
||||
this.plugin.wrapper = this;
|
||||
} catch (ClassNotFoundException e) {
|
||||
IOException ioe = new IOException("Unable to load " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
} catch (IllegalAccessException e) {
|
||||
IOException ioe = new IOException("Unable to create instance of " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
} catch (InstantiationException e) {
|
||||
IOException ioe = new IOException("Unable to create instance of " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
}
|
||||
this.plugin = (Plugin)plugin;
|
||||
this.plugin.wrapper = this;
|
||||
} catch (ClassNotFoundException e) {
|
||||
IOException ioe = new IOException("Unable to load " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
} catch (IllegalAccessException e) {
|
||||
IOException ioe = new IOException("Unable to create instance of " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
} catch (InstantiationException e) {
|
||||
IOException ioe = new IOException("Unable to create instance of " + className + " from " + archive);
|
||||
ioe.initCause(e);
|
||||
throw ioe;
|
||||
}
|
||||
|
||||
// initialize plugin
|
||||
try {
|
||||
plugin.setServletContext(owner.context);
|
||||
plugin.start();
|
||||
} catch(Throwable t) {
|
||||
// gracefully handle any error in plugin.
|
||||
IOException ioe = new IOException("Failed to initialize");
|
||||
ioe.initCause(t);
|
||||
throw ioe;
|
||||
// initialize plugin
|
||||
try {
|
||||
plugin.setServletContext(owner.context);
|
||||
plugin.start();
|
||||
} catch(Throwable t) {
|
||||
// gracefully handle any error in plugin.
|
||||
IOException ioe = new IOException("Failed to initialize");
|
||||
ioe.initCause(t);
|
||||
throw ioe;
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user