Skip to content

Commit

Permalink
Attempt to solve a NPE, possibly due to concurrent usage of ManifestV…
Browse files Browse the repository at this point in the history
…erifier
  • Loading branch information
TomasHofman committed Nov 1, 2024
1 parent 339d2c6 commit fb9612c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/java/org/jboss/set/components/ManifestVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -118,13 +117,11 @@ private static ArtifactCoordinate stream2Coord(Stream stream) {
}

static class BuildRecorder {
Map<PncComponent, Map<PncBuild.Id, Collection<ArtifactCoordinate>>> buildsByComponent = new HashMap<>();
Map<PncComponent, Map<PncBuild.Id, Collection<ArtifactCoordinate>>> buildsByComponent = new ConcurrentHashMap<>();
void record(PncBuild.Id buildId, PncComponent component, ArtifactCoordinate artifactCoordinate) {
buildsByComponent.putIfAbsent(component, new ConcurrentHashMap<>());

buildsByComponent.get(component).putIfAbsent(buildId, new ConcurrentLinkedQueue<>());

buildsByComponent.get(component).get(buildId).add(artifactCoordinate);
Map<PncBuild.Id, Collection<ArtifactCoordinate>> buildToArtifacts = buildsByComponent.computeIfAbsent(component, k -> new ConcurrentHashMap<>());
Collection<ArtifactCoordinate> artifacts = buildToArtifacts.computeIfAbsent(buildId, k -> new ConcurrentLinkedQueue<>());
artifacts.add(artifactCoordinate);
}

Collection<PncComponent> recordedComponents() {
Expand Down

0 comments on commit fb9612c

Please sign in to comment.