Fix NPE on a recursive property reference in a list field - #13099
Open
renechoi wants to merge 1 commit into
Open
Fix NPE on a recursive property reference in a list field#13099renechoi wants to merge 1 commit into
renechoi wants to merge 1 commit into
Conversation
DefaultModelInterpolator records an ERROR and returns null when the interpolator throws on a recursive variable reference. The generated transformer stores that null in List<String> model fields such as build/filters, whose Properties sibling branch already guards against it, and the immutable model constructor then copies the list with List.copyOf. The build fails with a bare NullPointerException instead of the "recursive variable reference" error that was just collected. Return the original text instead, which is what the Properties branch and StringVisitorModelInterpolator (MNG-8174) already do. The returned instance is identical, so the transformer's newVal != oldVal check stays false and unaffected models are still returned unchanged.
gnodet-bot
approved these changes
Sep 11, 2026
gnodet-bot
left a comment
There was a problem hiding this comment.
Clean, minimal fix. Returning the original text on an InterpolatorException instead of null is the correct approach — the error is already collected in the problem collector, and the build will fail with a clear "recursive variable reference" message. Returning null caused a secondary NullPointerException in List.copyOf() that masked the real error.
Consistent with DecryptingSettingsTransformer and the Maven 3 fix (MNG-8174 / #12932).
Test covers the exact failure path: recursive properties in a List<String> model field (build/filters).
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Category | (unlabeled) | bug |
| Labels | (none) | + bug |
| Milestone | (none) | 4.1.0 |
🔀 Backport Status
master but no backport PRs were found for:
maven-4.0.x— no backport PR found (author mentions willingness to open one)
This review was generated by an AI agent, Hermès on behalf of @gnodet.
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.
On a recursive reference
DefaultModelInterpolatorrecords an ERROR and returnsnull. The transformer writes it intoList<String>fields such asbuild/filters(itsPropertiesbranch already guards), and the immutable constructor callsList.copyOf, so the build dies with a bare NPE that hides the collected error:Returning the original text fixes it at the source instead of in the generated template, and matches
DecryptingSettingsTransformerand MNG-8174 (#12932), which covered Maven 3 only.The new test fails on master with that NPE. Full
mvn test: 3136 tests, 0 failures. Can open amaven-4.0.xbackport.