From 5f06b2194a19a42e1c493c274d1d68d1228e0555 Mon Sep 17 00:00:00 2001 From: Devin Nusbaum Date: Thu, 28 Mar 2024 16:47:44 -0400 Subject: [PATCH] Try to fix synchronization in SemaphoreStep --- .../plugins/workflow/test/steps/SemaphoreStep.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/workflow/test/steps/SemaphoreStep.java b/src/test/java/org/jenkinsci/plugins/workflow/test/steps/SemaphoreStep.java index b9ed24e2..0bacf24c 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/test/steps/SemaphoreStep.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/test/steps/SemaphoreStep.java @@ -189,6 +189,7 @@ 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; @@ -196,6 +197,8 @@ public static class Execution extends AbstractStepExecutionImpl { } else if (s.errors.containsKey(k)) { failure = true; error = s.errors.get(k); + } else { + s.contexts.put(k, c); } } if (success) { @@ -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) {