[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
This commit is contained in:
Stefan Oehme 2019-07-23 12:25:34 +02:00 committed by Michael Osipov
parent dd0776d949
commit 0515cb1f0e
1 changed files with 4 additions and 16 deletions

View File

@ -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,