elharo opened a new issue, #12599:
URL: https://github.com/apache/maven/issues/12599
# 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()`:
```java
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]