Skip to content

Commit

Permalink
[FIXED JENKINS-39168] NPE from last update.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Oct 21, 2016
1 parent 64083be commit be5984a
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -6,6 +6,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -121,13 +122,19 @@ public String getUrlName() {

public synchronized void add(@Nonnull InputStepExecution step) throws IOException, InterruptedException, TimeoutException {
loadExecutions();
if (executions == null) {
throw new IOException("cannot load state");
}
this.executions.add(step);
ids.add(step.getId());
run.save();
}

public synchronized InputStepExecution getExecution(String id) throws InterruptedException, TimeoutException {
loadExecutions();
if (executions == null) {
return null;
}
for (InputStepExecution e : executions) {
if (e.input.getId().equals(id))
return e;
Expand All @@ -137,6 +144,9 @@ public synchronized InputStepExecution getExecution(String id) throws Interrupte

public synchronized List<InputStepExecution> getExecutions() throws InterruptedException, TimeoutException {
loadExecutions();
if (executions == null) {
return Collections.emptyList();
}
return new ArrayList<InputStepExecution>(executions);
}

Expand All @@ -145,6 +155,9 @@ public synchronized List<InputStepExecution> getExecutions() throws InterruptedE
*/
public synchronized void remove(InputStepExecution exec) throws IOException, InterruptedException, TimeoutException {
loadExecutions();
if (executions == null) {
throw new IOException("cannot load state");
}
executions.remove(exec);
ids.remove(exec.getId());
run.save();
Expand Down

0 comments on commit be5984a

Please sign in to comment.