Skip to content

Commit

Permalink
Handle completed with no result set and note double onLoad calls
Browse files Browse the repository at this point in the history
  • Loading branch information
svanoort committed Apr 25, 2018
1 parent e303ff9 commit 9964f77
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,19 @@ private String key() {
@Override protected void onLoad() {
try {
synchronized (getLogCopyGuard()) { // CHECKME: Deadlock risks here - copyLogGuard and locks on Run
boolean completedStateNotPersisted = completed == null;
if (executionLoaded) {
LOGGER.log(Level.WARNING, "Double onLoad of build "+this);
return;
}
boolean needsToPersist = completed == null;
super.onLoad();

if (completed == Boolean.TRUE && result == null) {
LOGGER.log(Level.FINE, "Completed build with no result set, defaulting to failure for"+this);
setResult(Result.FAILURE);
needsToPersist = true;
}

// TODO See if we can simplify this, especially around interactions with 'completed'.

if (execution != null && completed != Boolean.TRUE) {
Expand All @@ -720,7 +730,7 @@ private String key() {
} else if (execution == null) {
completed = Boolean.TRUE;
}
if (completedStateNotPersisted && completed) {
if (needsToPersist && completed) {
try {
save();
} catch (Exception ex) {
Expand Down

0 comments on commit 9964f77

Please sign in to comment.