You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/08/28 13:26:05 UTC
(maven) branch master updated: Fix #12607: prevent session scope leak on MavenChainedWorkspaceReader constructor exception (#12863)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 5ae676d2cb Fix #12607: prevent session scope leak on MavenChainedWorkspaceReader constructor exception (#12863)
5ae676d2cb is described below
commit 5ae676d2cbdf7617c747e66a6b8513603cf7c92c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Aug 28 15:25:59 2026 +0200
Fix #12607: prevent session scope leak on MavenChainedWorkspaceReader constructor exception (#12863)
Move MavenChainedWorkspaceReader construction before sessionScope.enter()
so that if the constructor throws, the session scope is never entered and
exit() does not need to run. Previously, the constructor call sat between
enter() and the try block, meaning any exception would skip the finally
block's sessionScope.exit(), leaking thread-local state.
Co-authored-by: Claude Opus 4.6 <no...@anthropic.com>
---
impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 23e85a14b0..4b9138479b 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -209,9 +209,9 @@ private MavenExecutionResult doExecute(MavenExecutionRequest request) {
// AbstractLifecycleParticipant lookups
// so that @SessionScoped components can be @Injected into AbstractLifecycleParticipants.
//
- sessionScope.enter();
MavenChainedWorkspaceReader chainedWorkspaceReader =
new MavenChainedWorkspaceReader(request.getWorkspaceReader(), ideWorkspaceReader);
+ sessionScope.enter();
try (CloseableSession closeableSession = newCloseableSession(request, chainedWorkspaceReader)) {
MavenSession session = new MavenSession(closeableSession, request, result);
session.setSession(defaultSessionFactory.newSession(session));