diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java index 0bd86c0949..cef192820a 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; /** * Starts the build life cycle @@ -144,6 +145,9 @@ public class LifecycleStarter finally { executor.shutdown(); + // If the builder has terminated with an exception we want to catch any stray threads before going + // to System.exit in the mavencli. + executor.awaitTermination( 5, TimeUnit.SECONDS ) ; } } else diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleThreadedBuilder.java index 8f0b407b56..a413b4d5fa 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleThreadedBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleThreadedBuilder.java @@ -66,12 +66,7 @@ public class LifecycleThreadedBuilder try { multiThreadedProjectTaskSegmentBuild( analyzer, reactorContext, session, service, taskSegment, projectBuildMap, muxer ); - if ( reactorContext.getReactorBuildStatus().isHalted() ) - { - break; - } - - if ( reactorContext.getReactorBuildStatus().isHalted() ) + if ( reactorContext.getReactorBuildStatus().isHalted( ) ) { break; }