[maven] branch MNG-6311 created (now 411e892)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven] branch MNG-6311 created (now 411e892)

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

slachiewicz pushed a change to branch MNG-6311
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at 411e892  [MNG-6311] Implement class-level ModelCache in DefaultProjectBuilder to solve slow pom resolutions

This branch includes the following new commits:

     new 411e892  [MNG-6311] Implement class-level ModelCache in DefaultProjectBuilder to solve slow pom resolutions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven] 01/01: [MNG-6311] Implement class-level ModelCache in DefaultProjectBuilder to solve slow pom resolutions

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

slachiewicz pushed a commit to branch MNG-6311
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 411e89268ec11d603b697db7661ca576f11ebf13
Author: Sylwester Lachiewicz <[hidden email]>
AuthorDate: Fri Nov 24 00:56:00 2017 +0100

    [MNG-6311] Implement class-level ModelCache in DefaultProjectBuilder to solve slow pom resolutions
   
    Fix by: David Churcher
---
 .../apache/maven/project/DefaultProjectBuilder.java | 21 +++++++++++++--------
 .../org/apache/maven/project/ReactorModelCache.java |  8 ++++----
 2 files changed, 17 insertions(+), 12 deletions(-)

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 279399a..1091a08 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<String, MavenProject> 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 6331157..343967d 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<CacheKey, Object> models = new HashMap<>( 256 );
+    private final Map<CacheKey, Object> models = new ConcurrentHashMap<>( 256 );
 
     public Object get( String groupId, String artifactId, String version, String tag )
     {