plugin manager: fix plugins with multiple dependencies
If one plugin has multiple dependencies this would throw a concurrent modification exception due to iterating the successors after removing the edge Fill out javadoc for topologicalSort Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -631,11 +631,14 @@ public class PluginManager
|
||||
/**
|
||||
* Topologically sort a graph. Uses Kahn's algorithm.
|
||||
*
|
||||
* @param graph
|
||||
* @param <T>
|
||||
* @return
|
||||
* @param graph - A directed graph
|
||||
* @param <T> - The type of the item contained in the nodes of the graph
|
||||
* @return - A topologically sorted list corresponding to graph.
|
||||
* <p>
|
||||
* Multiple invocations with the same arguments may return lists that are not equal.
|
||||
*/
|
||||
private <T> List<T> topologicalSort(Graph<T> graph)
|
||||
@VisibleForTesting
|
||||
static <T> List<T> topologicalSort(Graph<T> graph)
|
||||
{
|
||||
MutableGraph<T> graphCopy = Graphs.copyOf(graph);
|
||||
List<T> l = new ArrayList<>();
|
||||
@@ -650,7 +653,7 @@ public class PluginManager
|
||||
|
||||
l.add(n);
|
||||
|
||||
for (T m : graphCopy.successors(n))
|
||||
for (T m : new HashSet<>(graphCopy.successors(n)))
|
||||
{
|
||||
graphCopy.removeEdge(n, m);
|
||||
if (graphCopy.inDegree(m) == 0)
|
||||
|
||||
Reference in New Issue
Block a user