Skip to content

Commit

Permalink
Merge pull request #6285 from bstansberry/WFCORE-7100
Browse files Browse the repository at this point in the history
[WFLY-7100] Use a concurrent set for ModuleSpecification.userDependen…
  • Loading branch information
yersan authored Dec 18, 2024
2 parents 600b226 + 8594f5a commit 6fdd6fe
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.function.Predicate;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -57,7 +58,7 @@ public class ModuleSpecification extends SimpleAttachable {
* <p/>
* User dependencies are not affected by exclusions.
*/
private final Set<ModuleDependency> userDependenciesSet = new HashSet<>();
private final Set<ModuleDependency> userDependenciesSet = new CopyOnWriteArraySet<>();

private final List<ResourceLoaderSpec> resourceLoaders = new ArrayList<>();

Expand Down Expand Up @@ -163,13 +164,19 @@ public void addUserDependencies(final Collection<ModuleDependency> dependencies)
*/
public void removeUserDependencies(final Predicate<ModuleDependency> predicate) {
Iterator<ModuleDependency> iter = userDependenciesSet.iterator();
while (iter.hasNext()) {
ModuleDependency md = iter.next();
Set<ModuleDependency> toRemove = null;
for (ModuleDependency md : userDependenciesSet) {
if (predicate.test(md)) {
iter.remove();
resetDependencyLists();
if (toRemove == null) {
toRemove = new HashSet<>();
}
toRemove.add(md);
}
}
if (toRemove != null) {
userDependenciesSet.removeAll(toRemove);
resetDependencyLists();
}
}

public void addLocalDependency(final ModuleDependency dependency) {
Expand Down

0 comments on commit 6fdd6fe

Please sign in to comment.