Skip to content

Commit

Permalink
[JENKINS-26761] Try using a PersistedList rather than a LinkedList fo…
Browse files Browse the repository at this point in the history
…r new WorkflowRun.checkouts.

(Existing build records will continue to use LinkedList.) Possible advantages:
· If the bug was caused by an unreported failure to serialize/deserialize an SCM instance,
  this would create a polite “old data” record instead.
  (CopyOnWriteArrayList would also work, via RobustCollectionConverter.)
· The backing store is CopyOnWriteList, solving a hypothetical ConcurrentModificationException.
· Additions from onCheckout should be saved to disk immediately, rather than waiting for some other save trigger.
Originally-Committed-As: ad9b6caf0428b9c85601ef9d349ca2691b7055be
  • Loading branch information
jglick committed Jul 28, 2015
1 parent f95817b commit c1eb2e2
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -51,6 +51,7 @@
import hudson.scm.SCM;
import hudson.scm.SCMRevisionState;
import hudson.util.NullStream;
import hudson.util.PersistedList;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -62,7 +63,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -130,7 +130,7 @@ public final class WorkflowRun extends Run<WorkflowJob,WorkflowRun> implements Q
public WorkflowRun(WorkflowJob job) throws IOException {
super(job);
firstTime = true;
checkouts = new LinkedList<SCMCheckout>();
checkouts = new PersistedList<SCMCheckout>(this);
//System.err.printf("created %s @%h%n", this, this);
}

Expand Down Expand Up @@ -531,7 +531,7 @@ public boolean hasntStartedYet() {
if (listener != null) {
listener.error("JENKINS-26761: list of SCM checkouts in " + this + " was lost; polling will be broken");
}
checkouts = new LinkedList<SCMCheckout>();
checkouts = new PersistedList<SCMCheckout>(this);
// Could this.save(), but might pollute diagnosis, and (worse) might clobber real data if there is >1 WorkflowRun with the same ID.
}
return checkouts;
Expand Down

0 comments on commit c1eb2e2

Please sign in to comment.