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:31:54 UTC
(maven) 01/01: 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 backport/12863
in repository https://gitbox.apache.org/repos/asf/maven.git
commit c0e77ff695af72fec8fd9718294eab1f51c1b3d8
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 e734f54f00..d362ef6374 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));