You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2019/07/26 21:38:53 UTC

[maven] 01/01: [MNG-6720] MultiThreadedBuilder: wait for parallel running projects when using --fail-fast

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

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

commit 0515cb1f0e258e1c22186a4e2dbdffa8db850b57
Author: Stefan Oehme <st...@gmail.com>
AuthorDate: Tue Jul 23 12:25:34 2019 +0200

    [MNG-6720] MultiThreadedBuilder: wait for parallel running projects when using --fail-fast
    
    Otherwise the sessionFinished event may be sent before some
    projects/goals finish, which violates the contracts of execution
    listeners and makes it hard to properly life cycle components that
    are needed for goal execution.
    
    This closes #272
---
 .../builder/multithreaded/MultiThreadedBuilder.java  | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
index bfbfb02..94d10af 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
@@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorCompletionService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.lifecycle.internal.BuildThreadFactory;
@@ -114,6 +114,9 @@ public class MultiThreadedBuilder
             }
 
         }
+
+        executor.shutdown();
+        executor.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS );
     }
 
     private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer,
@@ -172,21 +175,6 @@ public class MultiThreadedBuilder
                 break;
             }
         }
-
-        // cancel outstanding builds (if any) - this can happen if an exception is thrown in above block
-
-        Future<ProjectSegment> unprocessed;
-        while ( ( unprocessed = service.poll() ) != null )
-        {
-            try
-            {
-                unprocessed.get();
-            }
-            catch ( InterruptedException | ExecutionException e )
-            {
-                throw new RuntimeException( e );
-            }
-        }
     }
 
     private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,