apache / apache/maven-jarsigner-plugin
ExecutorService leak in processArchives if stream pipeline throws
- Dominant language
- Java
- Stars
- 23
- Forks
- 18
- Avg merge
- 4h 23m
- Merged PRs (30d)
- 2
Description
**Affected version:** HEAD
**File:** `src/main/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojo.java:329-353`
The `ProcessArchives()` method creates an `ExecutorService` outside the try-finally block:
```java
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
List> futures = archives.stream()
.map(file -> executor.submit((Callable) () -> {
processArchive(file);
return null;
}))
.collect(Collectors.toList());
try {
for (Future future : futures) {
future.get();
}
} catch (...) {
...
} finally {
executor.shutdownNow();
}
```
If the stream pipeline (`.map(...)`, `.collect(...)`) throws an exception (e.g., an `OutOfMemoryError` during task submission), the executor is never shut down, leaving its threads running indefinitely. This could cause resource leaks in large builds.
The fix should move the executor creation inside the try block or wrap the entire pipeline in the try-finally.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojo.java:329-353 and inspect the ProcessArchives() executor setup and stream pipeline. Ensure the executor is shut down when task submission or collection throws, as well as during the existing completion handling. Done means the pipeline cannot leave executor threads running after an exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 83/100