Skip to content

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

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
fix-12301
Jun 18, 2026
Merged

[#12301] Fix StackOverflowError with internal parent and CI-friendly revision#12314
gnodet merged 1 commit into
maven-4.0.xfrom
fix-12301

Conversation

@gnodet

@gnodet gnodet commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

When a multi-module project uses CI-friendly ${revision} with an internal parent in a subdirectory and a .mvn/ root marker, Maven 4 enters infinite recursion in DefaultModelBuilder:

readFileModel → getEnhancedProperties → doReadFileModel → cache → readFileModel → …

The cycle occurs because getEnhancedProperties() reads the root model to resolve CI-friendly properties, which triggers doReadFileModel() for the root POM, which calls getEnhancedProperties() again.

Fix

Added a shared Set<Path> activeModelReads to ModelBuilderSessionState that tracks which POM files are currently being read in an outer call frame. When getEnhancedProperties() detects that the root model is already being read (i.e., we're in a recursive call), it skips reading the root model to break the cycle.

The set is:

  • Shared across all derived sessions (passed through derive())
  • Thread-safe (ConcurrentHashMap.newKeySet())
  • Self-cleaning (entries are removed in a finally block)

Integration Test

Added MavenITgh12301StackOverflowInternalParentRevisionTest with a reproducer project that has:

  • A root POM with ${revision} and .mvn/ marker
  • An internal parent module in a subdirectory

Fixes #12301

…revision

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested a review from cstamas June 18, 2026 17:24
@gnodet gnodet merged commit f6132d9 into maven-4.0.x Jun 18, 2026
24 checks passed
@gnodet gnodet deleted the fix-12301 branch June 18, 2026 21:41
@github-actions

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

@github-actions github-actions Bot added this to the 4.0.0-rc-6 milestone Jun 18, 2026
@gnodet gnodet added the bug Something isn't working label Jun 18, 2026
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