Skip to content

Commit

Permalink
Merge pull request #258 from dwnusbaum/synchronization-fix
Browse files Browse the repository at this point in the history
Try to fix synchronization in `SemaphoreStep`
  • Loading branch information
dwnusbaum authored Mar 29, 2024
2 parents 1e84e32 + 5f06b21 commit 175aa9c
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ public static class Execution extends AbstractStepExecutionImpl {
Object returnValue = null;
Throwable error = null;
boolean success = false, failure = false, sync = true;
String c = Jenkins.XSTREAM.toXML(getContext());
synchronized (s) {
if (s.returnValues.containsKey(k)) {
success = true;
returnValue = s.returnValues.get(k);
} else if (s.errors.containsKey(k)) {
failure = true;
error = s.errors.get(k);
} else {
s.contexts.put(k, c);
}
}
if (success) {
Expand All @@ -206,10 +209,6 @@ public static class Execution extends AbstractStepExecutionImpl {
getContext().onFailure(error);
} else {
LOGGER.info(() -> "Blocking " + k);
String c = Jenkins.XSTREAM.toXML(getContext());
synchronized (s) {
s.contexts.put(k, c);
}
sync = false;
}
synchronized (s) {
Expand Down

0 comments on commit 175aa9c

Please sign in to comment.