2
votes

In my BPMN file I have an gateway defined as follows:

<exclusiveGateway id="gateway" name="An gateway"/>

<sequenceFlow id="sequence1" sourceRef="gateway"
        targetRef="task1">
    <conditionExpression xsi:type="tFormalExpression">${variableABC == true}
    </conditionExpression>
</sequenceFlow>

<sequenceFlow id="sequence2" sourceRef="gateway"
        targetRef="task2">
        <conditionExpression xsi:type="tFormalExpression">${variableABC == false}
    </conditionExpression>
</sequenceFlow>

I wonder what is going to happen when the variable variableABC is missing (not set in the workflow engine)?

From my tests it seems that the flow will go to second branch. Could anyone explain why?

In Java null == false would throw an exception (?). How does activiti engine works in this situation? Thanks

2

2 Answers

0
votes

I tried to deploy the workflow similar to above one, but I am not able to deploy it. Its giving me an error

org.activiti.engine.ActivitiException: Unknown property used in expression: ${variableABC == true}

then I changed it to

[CDATA[${execution.getVariable('variableABC') == true}]]

[CDATA[${execution.getVariable('variableABC') == false}]]

[CDATA[${execution.getVariable('variableABC') == null}]]

After this I was able to deploy it and run my tests successfully.

Observations:

  1. It has never gone to "false" sequence flow when I had above 3 sequence flow
  2. When I removed last sequence flow i.e. checking with null, I got error org.activiti.engine.ActivitiException: No outgoing sequence flow of the exclusive gateway 'exclusivegateway1' could be selected for continuing the process

So I think there is no issue with activiti. You just verify your workflow properly.

:)

0
votes

Of course, it will go to the Second path if no value is provided. by default value of boolean is always false. it's a common java logic. for String, If no default path is provided then null value of expression, Activiti will throw an exception saying - no path/default found after Gateway.