mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
Add detection of circular dependencies
This commit is contained in:
@@ -29,6 +29,8 @@ class SmpNodeBuilder {
|
||||
otherNode.addChild(node);
|
||||
}
|
||||
});
|
||||
|
||||
nodes.forEach(this::checkForCircle);
|
||||
});
|
||||
|
||||
return nodes;
|
||||
@@ -47,4 +49,18 @@ class SmpNodeBuilder {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkForCircle(PluginNode pluginNode) {
|
||||
pluginNode.getChildren().forEach(child -> assertDoesNotContainsDependency(pluginNode, child));
|
||||
}
|
||||
|
||||
private void assertDoesNotContainsDependency(PluginNode pluginNode, PluginNode childNode) {
|
||||
if (childNode == pluginNode) {
|
||||
throw new PluginCircularDependencyException("circular dependency detected: " +
|
||||
childNode.getId() + " depends on " + pluginNode.getId() + " and " +
|
||||
pluginNode.getId() + " depends on " + childNode.getId()
|
||||
);
|
||||
}
|
||||
childNode.getChildren().forEach(child -> assertDoesNotContainsDependency(pluginNode, child));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user