Skip to content

Commit

Permalink
Fixed NPE during reporting (#318)
Browse files Browse the repository at this point in the history
* Fixed potential NullPointerException.

There is evidence that the key sets of the sourceProxies and reporters
maps get inconsistent. I observe randomly failing builds that report the
following error:

```
FATAL: Cannot invoke "java.util.List.iterator()" because the return
value of "java.util.Map.get(Object)" is null
java.lang.NullPointerException: Cannot invoke
"java.util.List.iterator()" because the return value of
"java.util.Map.get(Object)" is null
	at hudson.maven.AbstractMavenBuilder.end(AbstractMavenBuilder.java:101)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:883)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
	at hudson.model.Run.execute(Run.java:1895)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
```

* Fixed indentation.
  • Loading branch information
haumacher authored Oct 2, 2023
1 parent f3c5ecc commit 8fba37a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/hudson/maven/AbstractMavenBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ protected AbstractMavenBuilder(BuildListener listener, Collection<MavenModule> m
void end(Launcher launcher) throws IOException, InterruptedException {
for (Map.Entry<ModuleName,ProxyImpl2> e : sourceProxies.entrySet()) {
ProxyImpl2 p = e.getValue();
for (MavenReporter r : reporters.get(e.getKey())) {
ModuleName module = e.getKey();
List<MavenReporter> moduleReporters = reporters.get(module);
if (moduleReporters == null) {

Check warning on line 103 in src/main/java/hudson/maven/AbstractMavenBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 103 is only partially covered, one branch is missing
// Safety: Key set of reporter and source list has become inconsistent.
continue;

Check warning on line 105 in src/main/java/hudson/maven/AbstractMavenBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 105 is not covered by tests
}
for (MavenReporter r : moduleReporters) {
// we'd love to do this when the module build ends, but doing so requires
// we know how many task segments are in the current build.
r.end(p.owner(),launcher,listener);
Expand Down

0 comments on commit 8fba37a

Please sign in to comment.