Skip to content

Commit

Permalink
[MNG-7716] ConcurrencyDependencyGraph deadlock if no root is selected
Browse files Browse the repository at this point in the history
If ConcurrencyDependencyGraph#getRootSchedulableBuilds returns an empty
list then MultiThreadedBuilder is locked forever as it never gets a
build result (because nothing is scheduled).

This changes the method, that in such case just the first project is
returned, this might not give the best performance, but ensures that
there is at least one build scheduled and the build-loop can proceed.
  • Loading branch information
Christoph Läubrich committed Mar 2, 2023
1 parent 7023ef7 commit 27868ab
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public List<MavenProject> getRootSchedulableBuilds() {
result.add(projectBuild.getProject());
}
}
if (result.isEmpty() && projectBuilds.size() > 0) {
// Must return at least one project
result.add(projectBuilds.get(0).getProject());
}
return new ArrayList<>(result);
}

Expand All @@ -93,14 +97,21 @@ private List<MavenProject> getSchedulableNewProcesses(MavenProject finishedProje
result.add(dependentProject);
}
}
if (result.isEmpty()) {
Set<MavenProject> unfinishedProjects = getUnfinishedProjects();
if (unfinishedProjects.size() > 0) {
// Must return at least one project
result.add(unfinishedProjects.iterator().next());
}
}
return result;
}

/**
* @return set of projects that have yet to be processed successfully by the build.
*/
public Set<MavenProject> getUnfinishedProjects() {
Set<MavenProject> unfinished = new HashSet<>(projectBuilds.getProjects());
Set<MavenProject> unfinished = new LinkedHashSet<>(projectBuilds.getProjects());
unfinished.removeAll(finishedProjects);
return unfinished;
}
Expand Down

0 comments on commit 27868ab

Please sign in to comment.