From f32c3dba9495e3b7d4a73de6d303ae2eedb769f5 Mon Sep 17 00:00:00 2001 From: Romain Manni-Bucau Date: Thu, 6 Sep 2018 11:08:14 +0200 Subject: [PATCH] [MNG-6471] Parallel builder should use the module name as thread name This closes #177 --- .../multithreaded/MultiThreadedBuilder.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 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 94d10af4b4..2688a6b435 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 @@ -186,12 +186,23 @@ public class MultiThreadedBuilder { public ProjectSegment call() { - // muxer.associateThreadWithProjectSegment( projectBuild ); - lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, - projectBuild.getProject(), taskSegment ); - // muxer.setThisModuleComplete( projectBuild ); + final Thread currentThread = Thread.currentThread(); + final String originalThreadName = currentThread.getName(); + currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() ); - return projectBuild; + try + { + // muxer.associateThreadWithProjectSegment( projectBuild ); + lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, + projectBuild.getProject(), taskSegment ); + // muxer.setThisModuleComplete( projectBuild ); + + return projectBuild; + } + finally + { + currentThread.setName( originalThreadName ); + } } }; }