提交 071f5f20 编写于 作者: K kohsuke

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
上级 c0d915b3
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册