apache / apache/maven-archiver
Potential NPE in BuildHelper.getPlugin() when getPluginsAsMap() returns null
- Dominant language
- Java
- Stars
- 13
- Forks
- 26
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 7
Description
**Affected version:** 4.0.0-beta-5+
**Description:**
`BuildHelper.getPlugin()` at line 85 delegates to the private `getPlugin(PluginContainer, String)` at line 110:
```java
private static Plugin getPlugin(PluginContainer container, String pluginGa) {
if (container == null) {
return null;
}
Map pluginsAsMap = container.getPluginsAsMap();
return pluginsAsMap.get(pluginGa); // NPE if pluginsAsMap is null
}
```
`PluginContainer.getPluginsAsMap()` is not documented as guaranteed non-null by the Maven API specification. If a model implementation returns `null` from this method, line 115 throws NPE.
This affects `discoverJavaRelease()` which is called during every manifest creation — a null here would crash all JAR/WAR/EAR archive generation.
**Impact:** Unlikely with standard Maven model implementations, but a ticking bomb if the API contract varies or a non-standard model is used.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in BuildHelper.getPlugin(PluginContainer, String) at the reported line and inspect existing tests around BuildHelper and PluginContainer behavior. Reproduce a case where getPluginsAsMap() returns null and add regression coverage; done when plugin lookup no longer throws for that model implementation and the test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100