GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Handle missing project index in forked executions by 2akouwu · Pull Request #12911 · apache/maven

Conversation

@2akouwu

@2akouwu 2akouwu commented Aug 29, 2026

Copy link
Copy Markdown

Fixes #12600.

Avoids auto-unboxing a missing reactor project index and reports a LifecycleExecutionException that identifies the missing project instead of a NullPointerException.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ulofiai
fix: handle missing forked project index
8185aa4
Signed-off-by: ulofiai <[email protected]>
elharo
elharo previously requested changes Aug 29, 2026
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Has this happened in production? It needs a test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@2akouwu

2akouwu commented Aug 29, 2026

Copy link
Copy Markdown
Author

I don't have a confirmed production occurrence. I picked this up from #12600, where the missing project ID can cause an NPE through auto-unboxing.

I'll add a regression test that reproduces the missing project-index entry and verifies that we get a LifecycleExecutionException with the relevant project information instead of an NPE.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gnodet
gnodet reviewed Aug 29, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

✅ Looks Good

The fix correctly addresses issue #12600 — changing int to Integer and adding a null check before auto-unboxing prevents the NPE when a forked execution references a project not in the reactor. The thrown LifecycleExecutionException uses the correct constructor and produces a descriptive error message naming the offending projectId.

Agree with @elharo's request for a regression test. The test should set up a MojoExecution with forked executions referencing a projectId absent from the reactor's ProjectIndex, then assert that executeForkedExecutions throws LifecycleExecutionException (not NullPointerException) with the expected message.

Note: A pre-existing design observation (not introduced by this PR): ProjectIndex exposes its internal maps via mutable getters (getProjects(), getIndices()), and those maps are mutated within the forked execution loop. This is fine in the current single-threaded usage but worth noting for future hardening.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone (none) 4.1.0

🔀 Backport Status

⚠️ The same vulnerable pattern (int index = projectIndex.getIndices().get(projectId)) exists in maintenance branches:

  • maven-3.9.x (line 425) — no backport PR found
  • maven-3.10.x (line 434) — no backport PR found
  • maven-4.0.x (line 441) — no backport PR found

Consider creating backport PRs once this fix (with test) is merged.


🤖 This review was generated by ForgeBot. Feedback? File an issue on the ForgeBot repo.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet @claude
Add test for forked execution project index null guard
73c51b7
Test originally written for PR apache#12907 (our parallel fix for apache#12600).
Contributed here since this PR has the better exception constructor
(includes MojoExecution and MavenProject context).

See: apache#12907

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gnodet gnodet mentioned this pull request Aug 29, 2026
Fix #12600: guard against NPE on missing project index in MojoExecutor #12907
Closed
1 of 2 tasks
@gnodet
gnodet dismissed elharo’s stale review August 29, 2026 15:15

Test has been added

gnodet
gnodet approved these changes Aug 29, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM — the null guard with the richer LifecycleExecutionException(String, MojoExecution, MavenProject) constructor is the right approach. Test coverage added and passing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet added the bug Something isn't working label Aug 29, 2026
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Aug 29, 2026
@gnodet gnodet added mvn4 mvn40 labels Aug 29, 2026
@gnodet
gnodet merged commit 327276e into apache:master Aug 29, 2026
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned gnodet Aug 29, 2026
This was referenced Aug 29, 2026
[backport 4.0.x] Fix #12600: handle missing project index in forked executions #12917
Merged
[backport 3.9.x] Fix #12600: handle missing project index in forked executions #12918
Merged
gnodet added a commit that referenced this pull request Aug 29, 2026
2ako ulofiai
@gnodet @claude
Fix #12600: handle missing project index in forked executions (#12911)
3591db2
* fix: handle missing forked project index

Signed-off-by: ulofiai <[email protected]>

* Add test for forked execution project index null guard

Test originally written for PR #12907 (our parallel fix for #12600).
Contributed here since this PR has the better exception constructor
(includes MojoExecution and MavenProject context).

See: #12907

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Signed-off-by: ulofiai <[email protected]>
Co-authored-by: ulofiai <[email protected]>
Co-authored-by: Guillaume Nodet <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
This was referenced Aug 29, 2026
Add unit test for #12600 null-guard in forked executions #12923
Merged
fix(maven): guard missing project index before auto-unbox #12832
Merged
shoemoney added a commit to shoemoney/maven that referenced this pull request Aug 29, 2026
@shoemoney
fix(maven): keep 'not in the reactor' wording in forked-execution errors
9057215
The enriched messages dropped the phrase MojoExecutorForkedExecutionTest
asserts on, breaking maven-core after apache#12911 landed on master. Restore the
original wording and keep the parallel-build/extension context appended.
@gnodet gnodet mentioned this pull request Aug 30, 2026
Fix: make ProjectIndex thread-safe for parallel builds (backport #12832) #12926
Merged
1 of 2 tasks
gnodet added a commit that referenced this pull request Aug 31, 2026
2ako ulofiai
@gnodet @claude
Fix #12600: handle missing project index in forked executions (#12911)
58bc9aa
* fix: handle missing forked project index

Signed-off-by: ulofiai <[email protected]>

* Add test for forked execution project index null guard

Test originally written for PR #12907 (our parallel fix for #12600).
Contributed here since this PR has the better exception constructor
(includes MojoExecution and MavenProject context).

See: #12907

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Signed-off-by: ulofiai <[email protected]>
Co-authored-by: ulofiai <[email protected]>
Co-authored-by: Guillaume Nodet <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
gnodet added a commit that referenced this pull request Aug 31, 2026
@gnodet 2ako
ulofiai @claude
Fix #12600: handle missing project index in forked executions (#12911) (
fef4727
#12918)

* fix: handle missing forked project index



* Add test for forked execution project index null guard

Test originally written for PR #12907 (our parallel fix for #12600).
Contributed here since this PR has the better exception constructor
(includes MojoExecution and MavenProject context).

See: #12907



---------

Signed-off-by: ulofiai <[email protected]>
Co-authored-by: 2ako <[email protected]>
Co-authored-by: ulofiai <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
gnodet added a commit that referenced this pull request Aug 31, 2026
@gnodet @claude
Fix #12600: handle missing project index in forked executions
897020c
Backport of #12911 (merged to master) to maven-3.10.x.
Guards against NullPointerException from auto-unboxing when
ProjectIndex.getIndices().get() returns null for a project not
in the reactor. Throws descriptive LifecycleExecutionException
instead.

Test adapted for 3.10.x (Java 8 APIs, @Inject field injection).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
gnodet added a commit that referenced this pull request Aug 31, 2026
@gnodet @claude
Fix #12600: handle missing project index in forked executions (#12923)
0acb4e6
Backport of #12911 (merged to master) to maven-3.10.x.
Guards against NullPointerException from auto-unboxing when
ProjectIndex.getIndices().get() returns null for a project not
in the reactor. Throws descriptive LifecycleExecutionException
instead.

Test adapted for 3.10.x (Java 8 APIs, @Inject field injection).

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

Reviewers

@gnodet gnodet gnodet approved these changes
@elharo elharo elharo left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

bug Something isn't working mvn4 mvn40

Projects

None yet

Milestone

4.0.0-rc-7

Development

Successfully merging this pull request may close these issues.

[maven-4.0.x] MojoExecutor: auto-unbox NPE on missing project index

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@2akouwu @gnodet @elharo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.