Skip to content

[#12301] Fix StackOverflowError with internal parent and CI-friendly revision - #12317

Merged
gnodet merged 1 commit into
masterfrom
cherry-pick-12314-to-master
Jun 18, 2026
Merged

gnodet merged 1 commit into
masterfrom
cherry-pick-12314-to-master

Conversation

@gnodet

@gnodet gnodet commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Forward-port of #12314 from maven-4.0.x to master.

Fixes StackOverflowError when a project has an internal parent in a subdirectory using CI-friendly ${revision} and a .mvn/ root marker (GH-12301).

The fix adds cycle detection in doReadFileModel() via a shared activeModelReads set that tracks paths currently being read, preventing recursive loops between parent resolution and enhanced property resolution.

IT adapted for master (no version-range constructor).

@gnodet gnodet added this to the 4.1.0 milestone Jun 18, 2026
@gnodet gnodet added the bug Something isn't working label Jun 18, 2026
@gnodet gnodet self-assigned this Jun 18, 2026
@gnodet
gnodet merged commit c4c7d2e into master Jun 18, 2026
0 of 2 checks passed
@gnodet
gnodet deleted the cherry-pick-12314-to-master branch June 18, 2026 21:47
@slawekjaranowski

Copy link
Copy Markdown
Member

@gnodet please check it, look like master branch stop build after this merge

gnodet added a commit that referenced this pull request Jun 19, 2026
gnodet added a commit that referenced this pull request Jun 19, 2026
…revision (#12323)

* [#12301] Fix StackOverflowError with internal parent and CI-friendly 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]>

* Refactor: pass activeModelReads through call stack instead of ThreadLocal

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]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants