Skip to content

Commit

Permalink
bugix/ protect internal data in multi thread env.
Browse files Browse the repository at this point in the history
Some mojo are declared thread safe.
  • Loading branch information
jgraglia authored and slawekjaranowski committed Sep 14, 2024
1 parent 10e07ce commit 4222b66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* under the License.
*/

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.commons.lang3.function.TriFunction;
import org.apache.commons.lang3.tuple.Triple;
Expand All @@ -32,7 +32,7 @@
public class ArtifactVersionsCache {
private TriFunction<AbstractVersionDetails, Optional<Segment>, Boolean, ?> cachedFunction;
private Map<Triple<? extends AbstractVersionDetails, Optional<Segment>, Boolean>, Object> updateCache =
new HashMap<>();
new ConcurrentHashMap<>();

/**
* Constructs a new instance given the concrete function for obtaining the details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -150,7 +151,7 @@ RuleSet getRuleSet() {
*
* @since 2.12
*/
private final Map<String, Rule> artifactBestFitRule = new HashMap<>();
private final Map<String, Rule> artifactBestFitRule = new ConcurrentHashMap<>();

private final List<RemoteRepository> remoteProjectRepositories;

Expand Down Expand Up @@ -441,7 +442,9 @@ protected Rule getBestFitRule(String groupId, String artifactId) {
bestFit = rule;
}

artifactBestFitRule.put(groupArtifactId, bestFit);
if (bestFit != null) {
artifactBestFitRule.put(groupArtifactId, bestFit);
}
return bestFit;
}

Expand Down

0 comments on commit 4222b66

Please sign in to comment.