From cfb075ac706b25df630f3671f61f8d8313e0f138 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 31 May 2016 21:39:31 +0200 Subject: [PATCH] [MNG-6030] ReactorModelCache do not used effectively after maven version 3.0.5 which cause a large memory footprint o Reintroduced ReactorModelCache reduces the memory footprint. --- .../maven/project/DefaultProjectBuilder.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 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 9d51a6d3a2..d064ab4cc4 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 @@ -116,14 +116,14 @@ public class DefaultProjectBuilder public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request ) throws ProjectBuildingException { - return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null ) ); + return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null, null ) ); } @Override public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request ) throws ProjectBuildingException { - return build( null, modelSource, new InternalConfig( request, null ) ); + return build( null, modelSource, new InternalConfig( request, null, null ) ); } private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config ) @@ -275,7 +275,7 @@ public class DefaultProjectBuilder request.setUserProperties( configuration.getUserProperties() ); request.setBuildStartTime( configuration.getBuildStartTime() ); request.setModelResolver( resolver ); - request.setModelCache( new ReactorModelCache() ); + request.setModelCache( config.modelCache ); return request; } @@ -294,7 +294,7 @@ public class DefaultProjectBuilder org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact ); - InternalConfig config = new InternalConfig( request, null ); + InternalConfig config = new InternalConfig( request, null, null ); boolean localProject; @@ -394,7 +394,9 @@ public class DefaultProjectBuilder ReactorModelPool modelPool = new ReactorModelPool(); - InternalConfig config = new InternalConfig( request, modelPool ); + ReactorModelCache modelCache = new ReactorModelCache(); + + InternalConfig config = new InternalConfig( request, modelPool, modelCache ); Map projectIndex = new HashMap<>( 256 ); @@ -913,11 +915,14 @@ public class DefaultProjectBuilder public final List repositories; public final ReactorModelPool modelPool; + + public final ReactorModelCache modelCache; - InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool ) + InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache ) { this.request = request; this.modelPool = modelPool; + this.modelCache = modelCache; session = LegacyLocalRepositoryManager.overlay( request.getLocalRepository(), request.getRepositorySession(), repoSystem );