Repository navigation
Merged
Conversation
… constructor exception 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 <[email protected]>
gnodet
commented
Aug 27, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
Summary
Correct and safe one-line reorder that eliminates a real thread-local leak. The MavenChainedWorkspaceReader constructor has no session scope dependency, and the reorder places sessionScope.enter() immediately before the try block, closing the exception gap.
No blocking issues found.
🔀 Backport Status
master but no backport PR was found for:
maven-4.0.x— has the identical vulnerable pattern (sessionScope.enter()followed by constructor beforetry)
Note: maven-3.9.x and maven-3.10.x do not have this bug — sessionScope.enter() directly precedes try in those branches.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
cstamas
approved these changes
Aug 28, 2026
gnodet
added a commit
that referenced
this pull request
Aug 28, 2026
… constructor exception (#12863) (#12895) 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 <[email protected]>
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Oct 26, 2026
Restore two upstream commits that were accidentally dropped when rebasing onto stacked/build-report: 1. DefaultMaven.java – session scope leak fix (apache#12629/apache#12863) Re-adds the outer try-finally around MavenChainedWorkspaceReader construction and the CloseableSession block so that sessionScope.exit() is always called even when the reader constructor throws. Without the try block the finally clause on the ARM try-with-resources is never reached. Restores commits 850d3de and 5ae676d from upstream/master. 2. DefaultMavenPluginManager.java – MNG-8765 pre-interpolation and concurrent realm disposal (beee0f0 + 6399a8e) Restores the interpolateConfiguration() method (and its helpers EXPRESSION_PATTERN / collectModelTimePropertyNames / containsRuntimeExpression / interpolateXmlNode) together with the two call-sites in loadV4Mojo and loadV3Mojo so that runtime ${...} property references are resolved before type converters run. Also restores the duplicate-realm disposal block in setupExtensionsRealm and the missing imports (HashSet, Properties, Set, Matcher, Pattern, NoSuchRealmException).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MavenChainedWorkspaceReaderconstruction beforesessionScope.enter()inDefaultMaven.doExecute()to prevent a session scope thread-local leak when the constructor throwsProblem
sessionScope.enter()was called at line 212, followed bynew MavenChainedWorkspaceReader(...)at lines 213-214, before thetryblock at line 215. If the constructor threw any exception, thesessionScope.exit()in thefinallyblock would never execute, leaking the session scope's thread-localScopeState.Fix
Reorder the two statements so the workspace reader is constructed first. Since
MavenChainedWorkspaceReaderhas no dependency on the session scope, this is safe. If its constructor throws, the scope was never entered, so no cleanup is needed.Test plan
maven-corepass (includingDefaultMavenTestandSessionScopeProxyTest)🤖 Generated with Claude Code