BuildPlanExecutor: Thread pool leaked on constructor exception
Found in: maven-4.0.x branch
File: impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java (line 214)
Severity: Medium
Description
The BuildContext constructor creates a thread pool and then calls buildInitialPlan():
BuildContext(MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments) {
...
this.executor = new PhasingExecutor(Executors.newFixedThreadPool(threads, new BuildThreadFactory()));
this.plan = buildInitialPlan(taskSegments);
}
buildInitialPlan() is called inside the constructor, before the try-with-resources in execute() begins. If buildInitialPlan() throws (e.g., PluginNotFoundException, LifecyclePhaseNotFoundException), the BuildContext constructor throws and close() is never called (the object was never fully constructed), leaving the thread pool running indefinitely as a resource leak.
BuildPlanExecutor: Thread pool leaked on constructor exception
Found in: maven-4.0.x branch
File:
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java(line 214)Severity: Medium
Description
The
BuildContextconstructor creates a thread pool and then callsbuildInitialPlan():buildInitialPlan()is called inside the constructor, before thetry-with-resourcesinexecute()begins. IfbuildInitialPlan()throws (e.g.,PluginNotFoundException,LifecyclePhaseNotFoundException), theBuildContextconstructor throws andclose()is never called (the object was never fully constructed), leaving the thread pool running indefinitely as a resource leak.