Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-49170] NPE can be thrown on null triggers list
Browse files Browse the repository at this point in the history
Protect about possible null value for the triggers attribute.

This shouldn't be possible now with the current code, so I suppose
from reading the code and doing some archeology that it was not
100% protected before 3ad2875 for
instance where I see some defensive checks were added.

Protecting against this seen in production:

```
java.lang.NullPointerException
	at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.stopTriggers(PipelineTriggersJobProperty.java:96)
	at org.jenkinsci.plugins.workflow.job.WorkflowJob.removeProperty(WorkflowJob.java:580)
	at hudson.model.Job.removeProperty(Job.java:535)
	at org.jenkinsci.plugins.workflow.job.WorkflowJob.setTriggers(WorkflowJob.java:540)
```
  • Loading branch information
batmat committed Jan 25, 2018
1 parent 5edc739 commit 9906156
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -70,6 +70,15 @@ public PipelineTriggersJobProperty(List<Trigger> triggers) {
}
}

@SuppressWarnings("unused") // called by deserialization
protected Object readResolve() {
if (triggers == null) {
LOGGER.log(Level.WARNING, "triggers attribute was null, this shouldn't happen.");
this.triggers = new ArrayList<>();
}
return this;
}

public void setTriggers(List<Trigger<?>> triggers) {
this.triggers = new ArrayList<>(triggers);
}
Expand Down

0 comments on commit 9906156

Please sign in to comment.