mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-09 01:56:03 +00:00
Hudson now detects a cyclic dependencies among plugins and report the error gracefully.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@25682 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
c0d915b33d
commit
071f5f20f1
1 file changed
+35
@@ -26,12 +26,16 @@ package hudson;
|
||||
import static hudson.init.InitMilestone.PLUGINS_PREPARED;
|
||||
import static hudson.init.InitMilestone.PLUGINS_STARTED;
|
||||
import static hudson.init.InitMilestone.PLUGINS_LISTED;
|
||||
|
||||
import hudson.PluginWrapper.Dependency;
|
||||
import hudson.init.InitStrategy;
|
||||
import hudson.model.AbstractModelObject;
|
||||
import hudson.model.Failure;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.UpdateCenter;
|
||||
import hudson.model.UpdateSite;
|
||||
import hudson.util.CyclicGraphDetector;
|
||||
import hudson.util.CyclicGraphDetector.CycleDetectedException;
|
||||
import hudson.util.Service;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
@@ -187,6 +191,36 @@ public final class PluginManager extends AbstractModelObject {
|
||||
});
|
||||
}
|
||||
|
||||
g.requires(PLUGINS_LISTED).add("Checking cyclic dependencies",new Executable() {
|
||||
/**
|
||||
* Makes sure there's no cycle in dependencies.
|
||||
*/
|
||||
public void run(Reactor reactor) throws Exception {
|
||||
try {
|
||||
new CyclicGraphDetector<PluginWrapper>() {
|
||||
@Override
|
||||
protected List<PluginWrapper> getEdges(PluginWrapper p) {
|
||||
List<PluginWrapper> next = new ArrayList<PluginWrapper>();
|
||||
addTo(p.getDependencies(),next);
|
||||
addTo(p.getOptionalDependencies(),next);
|
||||
return next;
|
||||
}
|
||||
|
||||
private void addTo(List<Dependency> dependencies, List<PluginWrapper> r) {
|
||||
for (Dependency d : dependencies) {
|
||||
PluginWrapper p = getPlugin(d.shortName);
|
||||
if (p!=null)
|
||||
r.add(p);
|
||||
}
|
||||
}
|
||||
}.run(getPlugins());
|
||||
} catch (CycleDetectedException e) {
|
||||
stop(); // disable all plugins since classloading from them can lead to StackOverflow
|
||||
throw e; // let Hudson fail
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
g.requires(PLUGINS_LISTED).attains(PLUGINS_PREPARED).add("Loading plugins",new Executable() {
|
||||
/**
|
||||
* Once the plugins are listed, schedule their initialization.
|
||||
@@ -402,6 +436,7 @@ public final class PluginManager extends AbstractModelObject {
|
||||
public void stop() {
|
||||
for (PluginWrapper p : activePlugins)
|
||||
p.stop();
|
||||
activePlugins.clear();
|
||||
// Work around a bug in commons-logging.
|
||||
// See http://www.szegedi.org/articles/memleak.html
|
||||
LogFactory.release(uberClassLoader);
|
||||
|
||||
Reference in new issue
Block a user