diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 279399add8..1091a084c9 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -105,6 +105,8 @@ public class DefaultProjectBuilder @Requirement private ProjectDependenciesResolver dependencyResolver; + private final ReactorModelCache modelCache = new ReactorModelCache(); + // ---------------------------------------------------------------------- // MavenProjectBuilder Implementation // ---------------------------------------------------------------------- @@ -113,14 +115,14 @@ public class DefaultProjectBuilder public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request ) throws ProjectBuildingException { - return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null, null ) ); + return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null ) ); } @Override public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request ) throws ProjectBuildingException { - return build( null, modelSource, new InternalConfig( request, null, null ) ); + return build( null, modelSource, new InternalConfig( request, null ) ); } private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config ) @@ -291,7 +293,7 @@ public class DefaultProjectBuilder org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact ); - InternalConfig config = new InternalConfig( request, null, null ); + InternalConfig config = new InternalConfig( request, null ); boolean localProject; @@ -353,9 +355,7 @@ public class DefaultProjectBuilder ReactorModelPool modelPool = new ReactorModelPool(); - ReactorModelCache modelCache = new ReactorModelCache(); - - InternalConfig config = new InternalConfig( request, modelPool, modelCache ); + InternalConfig config = new InternalConfig( request, modelPool ); Map projectIndex = new HashMap<>( 256 ); @@ -943,11 +943,11 @@ public class DefaultProjectBuilder private final ReactorModelCache modelCache; - InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache ) + InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool ) { this.request = request; this.modelPool = modelPool; - this.modelCache = modelCache; + this.modelCache = getModelCache(); session = LegacyLocalRepositoryManager.overlay( request.getLocalRepository(), request.getRepositorySession(), repoSystem ); @@ -956,4 +956,9 @@ public class DefaultProjectBuilder } + private ReactorModelCache getModelCache() + { + return this.modelCache; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java b/maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java index 63311579a8..343967da37 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java @@ -19,11 +19,11 @@ package org.apache.maven.project; * under the License. */ -import java.util.HashMap; -import java.util.Map; - import org.apache.maven.model.building.ModelCache; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + /** * A simple model cache used to accelerate model building during a reactor build. * @@ -33,7 +33,7 @@ class ReactorModelCache implements ModelCache { - private final Map models = new HashMap<>( 256 ); + private final Map models = new ConcurrentHashMap<>( 256 ); public Object get( String groupId, String artifactId, String version, String tag ) {