Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugix/ protect internal data in multi thread env. #1133

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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