Skip to content

Fix NPE in DefaultModelBuilder#11922

Open
utafrali wants to merge 1 commit intoapache:masterfrom
utafrali:fix/issue-11919-maven-4-rc5-fails-with-npe-in-defaultmod
Open

Fix NPE in DefaultModelBuilder#11922
utafrali wants to merge 1 commit intoapache:masterfrom
utafrali:fix/issue-11919-maven-4-rc5-fails-with-npe-in-defaultmod

Conversation

@utafrali
Copy link
Copy Markdown

Fixes #11919

Got an NPE in DefaultModelBuilder when reading the effective model with Maven 4 RC5. The code was already checking if parentModel has a pom file, but then it was calling getPomFile() on inputModel without checking if it was null. Added the null check before using it.

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write unit tests that match behavioral changes.
  • Run mvn verify to make sure basic checks pass.
  • You have run the Core IT successfully.

@cstamas cstamas requested a review from gnodet April 10, 2026 12:50
@waterlx
Copy link
Copy Markdown

waterlx commented Apr 13, 2026

@utafrali @gnodet @cstamas Thank you for the fix and reviewing!
@cstamas My pleasure to meet you again 8-) I came from this Nisse issue

if (inputModel.getParent() != null && inputModel.getParent().getRelativePath() == null) {
String relPath;
if (parentModel.getPomFile() != null && isBuildRequest()) {
if (parentModel.getPomFile() != null && inputModel.getPomFile() != null && isBuildRequest()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just try to understand if it is as expected / a correct behavior to fall back inputModel's relPath to ".." when its getPomFile() is null.
Non-binding +1.

Copy link
Copy Markdown

@waterlx waterlx Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment has been resolved, but my "Resolve comment" is rejected by 401 (I have no idea why...). Please kindly move forward. Thank you!

@utafrali
Copy link
Copy Markdown
Author

Yep, that's expected - when getPomFile() is null, we fall back to '..' to keep a valid path for the model hierarchy.

@utafrali
Copy link
Copy Markdown
Author

no problem, moving forward with the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maven 4 (rc5) fails with NPE in DefaultModelBuilder

2 participants