gnodet opened a new pull request, #12996: URL: https://github.com/apache/maven/pull/12996
## Summary - Adds a `checkContainer()` null guard to the deprecated `MavenSession.lookup()`, `lookupList()`, and `lookupMap()` methods - When `PlexusContainer` is not injected (Maven 4 default), these methods now throw a descriptive `UnsupportedOperationException` with a migration message instead of a confusing `NullPointerException` - Adds `MavenSessionTest` with 7 test cases covering both the null-container (Maven 4) and populated-container (Maven 3) paths ## Context In Maven 4, the primary `MavenSession` constructor no longer accepts a `PlexusContainer` and sets the field to `null`. Plugins using the deprecated `MavenSession.lookup()` API (e.g., `gmaven-plugin:1.0` used by servicemix) get a cryptic NPE: ``` Cannot invoke "org.codehaus.plexus.PlexusContainer.lookup(String)" because "this.container" is null ``` The fix replaces this NPE with a clear `UnsupportedOperationException`: ``` PlexusContainer is not available in this session. Plugins should use JSR 330 (@Inject) injection instead of MavenSession.lookup(). The MavenSession Plexus lookup methods are deprecated. ``` ## Test plan - [x] New `MavenSessionTest` (7 tests) — all pass - [x] Full `maven-core` test suite (650 tests) — all pass - [x] Full reactor build (`mvn verify -DskipTests`) — BUILD SUCCESS 🤖 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
