You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/03/13 08:08:12 UTC

[maven] branch master updated: [MNG-5669] Fix infinitive loop in case pom.xml is being updated during the process (e.g. maven-shade-plugin writing reduced-pom with excluded dependencies)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5cdb833  [MNG-5669] Fix infinitive loop in case pom.xml is being updated during the process (e.g. maven-shade-plugin writing reduced-pom with excluded dependencies)
5cdb833 is described below

commit 5cdb8332f99a36e5a1da202da43e3c7dfbb49322
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Mar 13 09:07:19 2020 +0100

    [MNG-5669] Fix infinitive loop in case pom.xml is being updated during the process (e.g. maven-shade-plugin writing reduced-pom with excluded dependencies)
---
 .../maven/model/building/DefaultModelBuilder.java  | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index cc1ba71..b72550b 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -539,10 +539,14 @@ public class DefaultModelBuilder
                 new FileModelSource( Objects.requireNonNull( pomFile, "neither pomFile nor modelSource can be null" ) );
         }
 
-        Model model = getModelFromCache( modelSource, request.getModelCache() );
-        if ( model != null )
+        Model model;
+        if ( pomFile == null )
         {
-            return model;
+            model = getModelFromCache( modelSource, request.getModelCache() );
+            if ( model != null )
+            {
+                return model;
+            }
         }
 
         problems.setSource( modelSource.getLocation() );
@@ -634,7 +638,14 @@ public class DefaultModelBuilder
             throw problems.newModelBuildingException();
         }
 
-        model.setPomFile( pomFile );
+        if ( pomFile != null )
+        {
+            model.setPomFile( pomFile );
+        }
+        else if ( modelSource instanceof FileModelSource )
+        {
+            model.setPomFile( ( (FileModelSource) modelSource ).getFile() );
+        }
 
         problems.setSource( model );
         modelValidator.validateRawModel( model, request, problems );
@@ -992,13 +1003,7 @@ public class DefaultModelBuilder
                 return null;
             }
 
-            File pomFile = null;
-            if ( candidateSource instanceof FileModelSource )
-            {
-                pomFile = ( (FileModelSource) candidateSource ).getPomFile();
-            }
-
-            candidateModel = readModel( candidateSource, pomFile, request, problems );
+            candidateModel = readModel( candidateSource, null, request, problems );
         }
         else
         {