Repository navigation
Handle null plugin maps in BuildHelper - #409
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
Minimal and correct defensive null check. The real PluginContainer.getPluginsAsMap() implementation (lazy init from @Nonnull plugins field) can never return null, but the method lacks a @Nonnull annotation — so coding defensively against the API contract is the right call. The test correctly exercises the fix path through the public getPlugin(Model, String) entry point.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
The one-line null check in getPlugin is correct and harmless. However, the test has issues that should be addressed before merge.
Note: in the current Maven 4 model, PluginContainer.getPluginsAsMap() never returns null — it lazily builds an immutable map from the plugins list, which itself defaults to emptyList() via ImmutableCollections.copy(null). So this fix is purely defensive against non-standard PluginContainer implementations. That's fine, but the test should reflect this reality.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after commit 3e89015 — all three previous findings are addressed:
- Mocking rationale comment — ✅ Class-level comment added explaining why mocking is necessary (standard model can't produce null maps).
- Full test suite verification — ✅ Confirmed
mvn verifypasses (99 tests, 0 failures). Mock intercepts correctly despitegetPluginsAsMap()being inherited fromPluginContainer. - Missing
getPluginManagement()null-map test — ✅getPluginHandlesNullPluginMapInPluginManagement()added, covering the second lookup path exactly as suggested.
Production code is minimal and correct. Tests are well-structured with proper assertions. Ready to merge.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
- Guard getPluginsAsMap() calls with null checks to prevent NPE when plugin management or build plugins map is absent - Add explanatory comment clarifying when null maps can occur (e.g. minimal POMs with no plugins section) - Add test coverage for null pluginManagement and null build plugins map cases
3e89015 to
e98958c
Compare
Summary
nullplugin map returned by a Maven model without throwing aNullPointerException.getPluginsAsMap()returnsnull.Fixes #368
Testing
mvn -Dspotless.skip=true -Dtest=BuildHelperTest test— passed.git diff --check— passed.Spotless was skipped for the focused local run because the installed formatter is incompatible with the current JDK environment.
AI assistance was used during implementation; the submitted changes were reviewed and validated against the issue and repository tests.