You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/08/24 12:10:06 UTC

[PR] Fix #12598: prevent StackOverflow from path representation mismatch in getEnhancedProperties [maven]

gnodet opened a new pull request, #12809:
URL: https://github.com/apache/maven/pull/12809

   ## Summary
   
   - Use `toAbsolutePath().normalize()` consistently for path comparisons in `DefaultModelBuilder.getEnhancedProperties()` and `doReadFileModel()` to prevent `StackOverflowError` when `rootDirectory` and `model.getProjectDirectory()` have different representations
   - The session's `rootDirectory` (from `RootLocator.findRoot()`) may not be normalized, while `model.getProjectDirectory()` (derived from `PathSource`) is always normalized — without consistent normalization, the root model can incorrectly enter the non-root branch and recursively trigger `readFileModel()`
   - Added a unit test that exercises the fix with non-normalized paths (using `project/parent/../pom.xml`)
   
   ## Test plan
   
   - [x] New unit test `testNoStackOverflowWithNonNormalizedRootDirectory` passes
   - [x] All 19 `DefaultModelBuilderTest` tests pass (18 existing + 1 new)
   - [x] Full reactor build passes (`mvn clean install -DskipTests`)
   - [ ] CI passes
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12598: prevent StackOverflow from path representation mismatch in getEnhancedProperties [maven]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on PR #12809:
URL: https://github.com/apache/maven/pull/12809#issuecomment-5398812438

   There is `maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java` in 3.x
   but not contains methods like `getEnhancedProperties`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12598: prevent StackOverflow from path representation mismatch in getEnhancedProperties [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #12809:
URL: https://github.com/apache/maven/pull/12809#issuecomment-5445151193

   ### 3.x Applicability
   
   Confirmed: this fix does **not** apply to Maven 3.x. The `getEnhancedProperties()` method (where the path comparison mismatch occurs) was introduced in Maven 4.x as part of the new `DefaultModelBuilder` in `maven-impl`. Maven 3.x uses a different model building implementation that doesn't have this code path.
   
   ### Unit Test Added
   
   Added a unit test (`testGetEnhancedPropertiesWithNonNormalizedRootDirectory`) that:
   
   1. Creates a project with a `.mvn/` root marker
   2. Builds it to get the `ModelBuilderSessionState` and root `Model`
   3. Adds a marker property to the model that doesn't exist in the POM on disk
   4. Calls `getEnhancedProperties` via reflection with a non-normalized `rootDirectory` (containing `/../` segments)
   5. Asserts the marker property is present in the result — proving the else-branch was taken (fix recognizes the paths as equal)
   
   **Verified**: test **passes** with the fix and **fails** without it.
   
   Without the fix, `Objects.equals(rootDirectory, model.getProjectDirectory())` sees the non-normalized and normalized paths as different, incorrectly enters the if-branch, and re-reads the model from disk (losing the marker). In a real Maven session where `session.getRootDirectory()` consistently returns non-normalized paths, this incorrect branch leads to recursive `readFileModel` calls and `StackOverflowError`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12598: prevent StackOverflow from path representation mismatch in getEnhancedProperties [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #12809:
URL: https://github.com/apache/maven/pull/12809


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org