mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-14 07:43:40 +01:00
Avoid ConcurrentModificationExceptions
AggregateMojo.getDescendants() can end up adding descendants while it's iterating over them. This separates the addition from the iteration to avoid this. Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
@@ -173,15 +173,14 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<MavenProject> addedDescendants = new HashSet<MavenProject>();
|
||||
for (MavenProject dec : descendants) {
|
||||
for (String mod : dec.getModules()) {
|
||||
try {
|
||||
File mpp = new File(dec.getBasedir(), mod);
|
||||
mpp = mpp.getCanonicalFile();
|
||||
if (mpp.compareTo(p.getBasedir()) == 0 && descendants.add(p)) {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug(String.format("Decendent module %s added", p.getName()));
|
||||
}
|
||||
if (mpp.compareTo(p.getBasedir()) == 0) {
|
||||
addedDescendants.add(p);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
@@ -190,6 +189,11 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (MavenProject addedDescendant : addedDescendants) {
|
||||
if (descendants.add(addedDescendant) && getLog().isDebugEnabled()) {
|
||||
getLog().debug(String.format("Decendent module %s added", addedDescendant.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (size != 0 && size != descendants.size());
|
||||
if (getLog().isDebugEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user