[Backport 4.0.x] Fix #12986: Throw descriptive UnsupportedOperationException instead of NPE in MavenSession.lookup() - #13020
Merged
gnodet merged 1 commit intoSep 2, 2026
Conversation
…f NPE in MavenSession.lookup() (#12996) * Fix #12986: Throw descriptive UnsupportedOperationException instead of NPE in MavenSession.lookup() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add happy-path delegation tests for lookupList and lookupMap Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix pre-existing compile error: remove stale PathTranslator reference in DefaultModelBuilderTest PathTranslator was removed from the public API in MNG-8749 but the test was not updated. Remove the stale lookup call to match the new DefaultProfileActivationContext constructor signature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
commented
Sep 2, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
Clean backport of #12996 to maven-4.0.x. The core MavenSession null-guard changes (checkContainer() + 4 lookup guards) and the new MavenSessionTest (9 test cases) are identical to the original. The one excluded hunk (DefaultModelBuilderTest.java — PathTranslator removal) is correctly omitted because maven-4.0.x still uses the old DefaultProfileActivationContext constructor that accepts PathTranslator (removed on master by MNG-8749). All 24 CI checks pass. LGTM.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
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.
Backport of #12996 to maven-4.0.x.
Summary
checkContainer()null guard to the deprecatedMavenSession.lookup(),lookupList(), andlookupMap()methodsPlexusContaineris not injected (Maven 4 default), these methods now throw a descriptiveUnsupportedOperationExceptionwith a migration message instead of a confusingNullPointerExceptionMavenSessionTestwith 7 test cases covering both the null-container (Maven 4) and populated-container (Maven 3) paths