This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit b2b84d66cc18dc737ad8985a8cec37796d7cc1dc
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Jun 7 06:43:49 2026 +0000

    Fix CachingArtifactTypeRegistry — use ConcurrentHashMap
    
    F-17: Replace plain HashMap with ConcurrentHashMap to prevent
    corruption when concurrent parallel stream workers query the
    artifact type registry simultaneously.
---
 .../internal/impl/collect/CachingArtifactTypeRegistry.java  | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git 
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/CachingArtifactTypeRegistry.java
 
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/CachingArtifactTypeRegistry.java
index 0ba77e1f2..2f30f2b10 100644
--- 
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/CachingArtifactTypeRegistry.java
+++ 
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/CachingArtifactTypeRegistry.java
@@ -18,8 +18,8 @@
  */
 package org.eclipse.aether.internal.impl.collect;
 
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.artifact.ArtifactType;
@@ -45,17 +45,10 @@ public class CachingArtifactTypeRegistry implements 
ArtifactTypeRegistry {
 
     private CachingArtifactTypeRegistry(ArtifactTypeRegistry delegate) {
         this.delegate = delegate;
-        types = new HashMap<>();
+        types = new ConcurrentHashMap<>();
     }
 
     public ArtifactType get(String typeId) {
-        ArtifactType type = types.get(typeId);
-
-        if (type == null) {
-            type = delegate.get(typeId);
-            types.put(typeId, type);
-        }
-
-        return type;
+        return types.computeIfAbsent(typeId, delegate::get);
     }
 }

Reply via email to