From 19a3ed5c2e35e8624e5bfa5758746fb8b705382b Mon Sep 17 00:00:00 2001 From: adriana-corui <54841592+adriana-corui@users.noreply.github.com> Date: Wed, 14 Dec 2022 13:55:35 +0200 Subject: [PATCH] join branches leftovers (#1391) --- .../lang/runtime/events/LanguageEventData.java | 9 +++++++++ .../lang/runtime/steps/AbstractExecutionData.java | 1 + .../lang/runtime/steps/ParallelLoopExecutionData.java | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/events/LanguageEventData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/events/LanguageEventData.java index 35b75b0433..6e7da65fef 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/events/LanguageEventData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/events/LanguageEventData.java @@ -55,6 +55,7 @@ public class LanguageEventData extends HashMap { public static final String PRODUCER_WORKER_UUID = "PRODUCER_WORKER_UUID"; public static final String ROBOT_UUID = "ROBOT_UUID"; public static final String ROBOT_GROUP_NAME = "ROBOT_GROUP_NAME"; + public static final String BRANCH_ID = "BRANCH_ID"; public enum StepType { FLOW("flow"), @@ -156,6 +157,14 @@ public void setPath(String path) { put(PATH, path); } + public String getBranchId() { + return (String) get(BRANCH_ID); + } + + public void setBranchId(String branchId) { + put(BRANCH_ID, branchId); + } + public String getResult() { return (String) get(RESULT); } diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java index 02d7f15235..a33d142da3 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java @@ -115,6 +115,7 @@ private static LanguageEventData getLanguageEventData(ExecutionRuntimeServices r eventData.setTimeStamp(new Date()); eventData.setExecutionId(runtimeServices.getExecutionId()); eventData.setPath(path); + eventData.setBranchId(runtimeServices.getBranchId()); return eventData; } diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ParallelLoopExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ParallelLoopExecutionData.java index 21eac30163..33ebf9c04a 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ParallelLoopExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ParallelLoopExecutionData.java @@ -56,6 +56,7 @@ import static java.lang.Integer.parseInt; import static org.apache.commons.collections4.CollectionUtils.isEmpty; import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; +import static org.apache.commons.lang3.BooleanUtils.isTrue; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.Validate.notNull; @@ -248,8 +249,8 @@ private void handleLastIteration(RunEnvironment runEnv, clearExecutionRuntimeForNextStep(executionRuntimeServices); runEnv.getExecutionPath().up(); - if (temporaryBranchesContext.size() < executionRuntimeServices.removeSplitDataSize()) { - throw new RuntimeException("Exception occurred when running lane"); + if (isTrue(executionRuntimeServices.removeBranchErrorKey())) { + throw new RuntimeException("Exception occurred during lane execution"); } Context flowContext = runEnv.getStack().popContext(); @@ -401,6 +402,8 @@ private void collectBranchesData( initialBranchContext, Pair.of(RuntimeConstants.BRANCH_RETURN_VALUES_KEY, executableReturnValues) ); + } else { + executionRuntimeServices.setBranchErrorKey(); } } } @@ -454,6 +457,7 @@ private void clearExecutionRuntimeForNextStep(ExecutionRuntimeServices execution executionRuntimeServices.removeRemainingBranches(); executionRuntimeServices.removeParallelTemporaryContext(); executionRuntimeServices.removeSplitData(); + executionRuntimeServices.removeSplitDataSize(); executionRuntimeServices.removeThrottleSize(); } }