Repository navigation
[#12301] Fix StackOverflowError with internal parent and CI-friendly revision - #12323
Merged
Merged
Conversation
…revision Re-forward-port the GH-12301 fix from maven-4.0.x to master, using ThreadLocal<Set<Path>> instead of the shared ConcurrentHashMap.newKeySet() that caused a race condition with PhasingExecutor parallel model loading. The original forward-port (#12317) used a shared set to track which POM files were being read by doReadFileModel(). This prevented the StackOverflowError from GH-12301, but caused false cycle detection when parallel threads in loadFilePom() read the same model simultaneously — breaking ConsumerPomBuilderTest.testSimpleConsumer. The fix uses ThreadLocal so each thread tracks only its own call stack, preventing actual recursive cycles within the same thread without blocking legitimate parallel reads across threads. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ocal Replace ThreadLocal<Set<Path>> with a stack-passed Set<Path> parameter threaded through readFileModel() → doReadFileModel() → getEnhancedProperties(). Each readFileModel() entry point creates a fresh HashSet, avoiding any shared mutable state between concurrent model-loading threads. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
@gnodet Please assign appropriate label to PR according to the type of change. |
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
Re-forward-port of the GH-12301 fix from
maven-4.0.xtomaster. The previous forward-port (#12317) was reverted because it brokeConsumerPomBuilderTest.testSimpleConsumer.Root cause of the breakage: The original fix used a shared
ConcurrentHashMap.newKeySet()(activeModelReads) to track which POM files were being read bydoReadFileModel(). WhenPhasingExecutorprocesses subprojects in parallel vialoadFilePom(), thread A adding a path to the shared set would cause thread B'sgetEnhancedProperties()to skip reading that same model — even though there was no actual recursion, just parallel reads.Fix: Replace the shared
ConcurrentHashMap.newKeySet()with aThreadLocal<Set<Path>>. Each thread tracks only its own call stack, preventing actual recursive cycles (the StackOverflowError from GH-12301) without blocking legitimate parallel reads across threads.ThreadLocal<Set<Path>> activeModelReadsis added toModelBuilderSessionStateand shared across allderive()-d sessionsdoReadFileModel()adds/removes the current path from the thread-local setgetEnhancedProperties()checks the thread-local set before reading the root modelTest plan
ConsumerPomBuilderTest(7 tests) — the test broken by the previous forward-portDefaultModelBuilderTest(12 tests) — model builder testsMavenITgh12301StackOverflowInternalParentRevisionTest— IT for the original issueCloses #12301
Fully automatic review from Claude Code