Skip to content

Commit

Permalink
fix flowName variable (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Oct 10, 2023
1 parent 8c55a50 commit 4a1eead
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Result afterCommand(Runtime runtime, VM vm, State state, ThreadId threadI
if (cmd instanceof FlowCallCommand) {
FlowCallCommand fcc = (FlowCallCommand) cmd;
FlowCall step = fcc.getStep();
String flowName = VMUtils.getLocal(state, threadId, "flowName");
String flowName = FlowCallCommand.getFlowName(state, threadId);
if (flowName == null) {
flowName = step.getFlowName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

public class FlowCallCommand extends StepCommand<FlowCall> {

private static final String FLOW_NAME_VARIABLE = "__flowName__b6bc6c58-c2bc-434c-9a6b-b0092237720b";

private static final long serialVersionUID = 1L;

public FlowCallCommand(FlowCall step) {
Expand Down Expand Up @@ -93,7 +95,11 @@ protected void execute(Runtime runtime, State state, ThreadId threadId) {
// push the out handler first so it executes after the called flow's frame is done
state.peekFrame(threadId).push(processOutVars);
state.pushFrame(threadId, innerFrame);
VMUtils.putLocal(innerFrame, "flowName", flowName);
VMUtils.putLocal(innerFrame, FLOW_NAME_VARIABLE, flowName);
}

public static String getFlowName(State state, ThreadId threadId) {
return VMUtils.getLocal(state, threadId, FLOW_NAME_VARIABLE);
}

private static class EvalVariablesCommand implements Command {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ public void test() throws Exception {
verify(processStatusCallback, times(1)).onRunning(instanceId);
}

@Test
public void testFlowNameVariable() throws Exception {
deploy("doNotTouchFlowNameVariable");

save(ProcessConfiguration.builder()
.build());

byte[] log = run();
assertLog(log, ".*flowName in inner flow: 'This is MY variable'.*");

verify(processStatusCallback, times(1)).onRunning(instanceId);
}

@Test
public void testStackTrace() throws Exception {
deploy("stackTrace");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
flows:
default:
- set:
testvar1: "test123"
flowName: "This is MY variable"
- log: "flowName: ${flowName}"
- call: innerFlow

innerFlow:
- log: "flowName in inner flow: '${flowName}'"
- if: "${flowName != 'This is MY variable'}"
then:
- throw: "Hands off my variable!!!!"

0 comments on commit 4a1eead

Please sign in to comment.