This is an automated email from the ASF dual-hosted git repository.
pefernan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie.git
The following commit(s) were added to refs/heads/main by this push:
new 11018ce9f47 [incubator-kie#7284] Improve JoinInstance inclusive
gateway handling to avoid premature completion (#7285)
11018ce9f47 is described below
commit 11018ce9f473f9296c0ac43047605d34aa83209b
Author: Martin Weiler <[email protected]>
AuthorDate: Fri Nov 13 03:30:57 2026 -0600
[incubator-kie#7284] Improve JoinInstance inclusive gateway handling to
avoid premature completion (#7285)
* Fix JoinInstance existsActiveDirectFlow check for processes containing
consecutive XOR gateways
* Fix JoinInstance.existsActiveDirectFlow check for process instances that
executed the inner loop multiple times
* Avoid infinite loop with connected XOR gateways
---
.../jbpm/workflow/instance/node/JoinInstance.java | 50 ++++-
...nclusiveGatewayWithChainedXorSplitsInLoop.bpmn2 | 219 +++++++++++++++++++++
.../BPMN2-InclusiveGatewayWithXorOnlyCycle.bpmn2 | 175 ++++++++++++++++
.../BPMN2-InclusiveJoinWithLoopIterations.bpmn2 | 172 ++++++++++++++++
.../src/test/java/org/jbpm/bpmn2/FlowTest.java | 123 ++++++++++++
5 files changed, 733 insertions(+), 6 deletions(-)
diff --git
a/kogito-jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/JoinInstance.java
b/kogito-jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/JoinInstance.java
index 2447373154d..821f5c84d60 100755
---
a/kogito-jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/JoinInstance.java
+++
b/kogito-jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/JoinInstance.java
@@ -192,11 +192,16 @@ public class JoinInstance extends NodeInstanceImpl {
});
for (NodeInstance nodeInstance : activeNodeInstances) {
- // do not consider NodeInstanceContainers to be checked, enough to
treat is as black box
- if (((org.jbpm.workflow.instance.NodeInstance)
nodeInstance).getLevel() != getLevel()) {
+ org.kie.api.definition.process.Node node = nodeInstance.getNode();
+ // An active node of another iteration (level) belongs to a
different pass through the join and is ignored when it is
+ // part of a loop that goes through the join, or when it is not
part of a loop at all (e.g. repeated timer or
+ // multi instance executions that pass the join independently).
+ // When it is part of a loop that is entirely within one of the
branches leading to the join, a later iteration of that
+ // loop is still the same logical token and the join has to wait
for it.
+ if (((org.jbpm.workflow.instance.NodeInstance)
nodeInstance).getLevel() != getLevel()
+ && (isReachable(lookFor, node) || !isReachable(node,
node))) {
continue;
}
- org.kie.api.definition.process.Node node = nodeInstance.getNode();
Set<WorkflowElementIdentifier> vistedNodes = new HashSet<>();
checkNodes(vistedNodes, node, node, lookFor);
if (vistedNodes.contains(lookFor.getId()) &&
!vistedNodes.contains(node.getId())) {
@@ -207,6 +212,37 @@ public class JoinInstance extends NodeInstanceImpl {
return false;
}
+ /**
+ * Checks whether {@code target} can be reached by following the outgoing
connections starting at {@code from}.
+ */
+ private boolean isReachable(org.kie.api.definition.process.Node from,
org.kie.api.definition.process.Node target) {
+ if (from == null || target == null) {
+ return false;
+ }
+ Set<WorkflowElementIdentifier> visited = new HashSet<>();
+ List<org.kie.api.definition.process.Node> pending = new ArrayList<>();
+ pending.add(from);
+ while (!pending.isEmpty()) {
+ org.kie.api.definition.process.Node current =
pending.remove(pending.size() - 1);
+ if (current instanceof AsyncEventNode) {
+ current = ((AsyncEventNode) current).getActualNode();
+ }
+ for (Connection conn :
current.getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE)) {
+ org.kie.api.definition.process.Node next = conn.getTo();
+ if (next == null) {
+ continue;
+ }
+ if (next.getId().equals(target.getId())) {
+ return true;
+ }
+ if (visited.add(next.getId())) {
+ pending.add(next);
+ }
+ }
+ }
+ return false;
+ }
+
private boolean checkNodes(Set<WorkflowElementIdentifier> vistedNodes,
org.kie.api.definition.process.Node startAt,
org.kie.api.definition.process.Node currentNode,
org.kie.api.definition.process.Node lookFor) {
if (currentNode == null) {
@@ -231,10 +267,12 @@ public class JoinInstance extends NodeInstanceImpl {
if (nextNode == null) {
continue;
} else {
- xorCopy.add(nextNode.getId());
- if (!nextNode.getId().equals(lookFor.getId())) {
+ boolean alreadyVisited = !xorCopy.add(nextNode.getId());
+ // a node already visited on this path must not be
explored again, otherwise a cycle of XOR splits never ends
+ if (!alreadyVisited &&
!nextNode.getId().equals(lookFor.getId())) {
- checkNodes(xorCopy, currentNode, nextNode, lookFor);
+ // keep the original start node as loop anchor so that
further XOR splits down the path are still explored
+ checkNodes(xorCopy, startAt, nextNode, lookFor);
}
}
diff --git
a/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithChainedXorSplitsInLoop.bpmn2
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithChainedXorSplitsInLoop.bpmn2
new file mode 100644
index 00000000000..f1ba4d3d7f5
--- /dev/null
+++
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithChainedXorSplitsInLoop.bpmn2
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
id="Definition" expressionLanguage="http://www.mvel.org/2.0"
targetNamespace="http://www.jboss.org/dr [...]
+ <itemDefinition id="_xItem" structureRef="Integer"/>
+ <process id="InclusiveGatewayWithChainedXorSplitsInLoop" tns:version="1"
tns:packageName="org.jbpm.bpmn2.flow" tns:adHoc="false"
name="InclusiveGatewayWithChainedXorSplitsInLoop" isExecutable="true"
processType="Private">
+ <property id="x" itemSubjectRef="_xItem"/>
+ <startEvent id="_1" name="Start">
+ <outgoing>_1-_2</outgoing>
+ </startEvent>
+ <inclusiveGateway id="_2" name="OR diverging" gatewayDirection="Diverging">
+ <incoming>_1-_2</incoming>
+ <outgoing>_2-_3</outgoing>
+ <outgoing>_2-_4</outgoing>
+ </inclusiveGateway>
+ <!-- Branch A -->
+ <task id="_3" tns:taskName="taskA" name="TaskA">
+ <incoming>_2-_3</incoming>
+ <outgoing>_3-_10</outgoing>
+ <ioSpecification id="InputOutputSpecification_1">
+ <inputSet id="InputSet_1"/>
+ <outputSet id="OutputSet_1"/>
+ </ioSpecification>
+ </task>
+ <!-- Branch B: loop containing two chained XOR splits -->
+ <exclusiveGateway id="_4" name="XOR converging"
gatewayDirection="Converging">
+ <incoming>_2-_4</incoming>
+ <incoming>_8-_4</incoming>
+ <outgoing>_4-_5</outgoing>
+ </exclusiveGateway>
+ <exclusiveGateway id="_5" name="XOR diverging before B1"
gatewayDirection="Diverging" default="_5-_6">
+ <incoming>_4-_5</incoming>
+ <outgoing>_5-_6</outgoing>
+ <outgoing>_5-_12</outgoing>
+ </exclusiveGateway>
+ <endEvent id="_12" name="Cancel End">
+ <incoming>_5-_12</incoming>
+ </endEvent>
+ <task id="_6" tns:taskName="taskB1" name="TaskB1">
+ <incoming>_5-_6</incoming>
+ <outgoing>_6-_7</outgoing>
+ <ioSpecification id="InputOutputSpecification_2">
+ <inputSet id="InputSet_2"/>
+ <outputSet id="OutputSet_2"/>
+ </ioSpecification>
+ </task>
+ <exclusiveGateway id="_7" name="XOR diverging after B1"
gatewayDirection="Diverging" default="_7-_10">
+ <incoming>_6-_7</incoming>
+ <outgoing>_7-_8</outgoing>
+ <outgoing>_7-_10</outgoing>
+ </exclusiveGateway>
+ <task id="_8" tns:taskName="taskB2" name="TaskB2">
+ <extensionElements>
+ <tns:onExit-script scriptFormat="http://www.java.com/java">
+ <tns:script>kcontext.setVariable("x", x + 1);</tns:script>
+ </tns:onExit-script>
+ </extensionElements>
+ <incoming>_7-_8</incoming>
+ <outgoing>_8-_4</outgoing>
+ <ioSpecification id="InputOutputSpecification_3">
+ <inputSet id="InputSet_3"/>
+ <outputSet id="OutputSet_3"/>
+ </ioSpecification>
+ </task>
+ <!-- Join and rest of the process -->
+ <inclusiveGateway id="_10" name="OR converging"
gatewayDirection="Converging">
+ <incoming>_3-_10</incoming>
+ <incoming>_7-_10</incoming>
+ <outgoing>_10-_11</outgoing>
+ </inclusiveGateway>
+ <task id="_11" tns:taskName="afterJoin" name="AfterJoinTask">
+ <incoming>_10-_11</incoming>
+ <outgoing>_11-_13</outgoing>
+ <ioSpecification id="InputOutputSpecification_4">
+ <inputSet id="InputSet_4"/>
+ <outputSet id="OutputSet_4"/>
+ </ioSpecification>
+ </task>
+ <endEvent id="_13" name="End">
+ <incoming>_11-_13</incoming>
+ </endEvent>
+ <sequenceFlow id="_1-_2" tns:priority="1" sourceRef="_1" targetRef="_2"/>
+ <sequenceFlow id="_2-_3" tns:priority="1" sourceRef="_2" targetRef="_3">
+ <conditionExpression xsi:type="tFormalExpression"
id="FormalExpression_1" language="http://www.java.com/java">return
true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_2-_4" tns:priority="1" sourceRef="_2" targetRef="_4">
+ <conditionExpression xsi:type="tFormalExpression"
id="FormalExpression_2" language="http://www.java.com/java">return
true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_3-_10" tns:priority="1" sourceRef="_3" targetRef="_10"/>
+ <sequenceFlow id="_4-_5" tns:priority="1" sourceRef="_4" targetRef="_5"/>
+ <sequenceFlow id="_5-_6" tns:priority="2" sourceRef="_5" targetRef="_6"/>
+ <sequenceFlow id="_5-_12" tns:priority="1" name="cancel" sourceRef="_5"
targetRef="_12">
+ <conditionExpression xsi:type="tFormalExpression"
id="FormalExpression_3" language="http://www.java.com/java">return
false;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_6-_7" tns:priority="1" sourceRef="_6" targetRef="_7"/>
+ <sequenceFlow id="_7-_8" tns:priority="1" name="loop" sourceRef="_7"
targetRef="_8">
+ <conditionExpression xsi:type="tFormalExpression"
id="FormalExpression_4" language="http://www.java.com/java">return x <
1;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_7-_10" tns:priority="2" name="proceed" sourceRef="_7"
targetRef="_10"/>
+ <sequenceFlow id="_8-_4" tns:priority="1" sourceRef="_8" targetRef="_4"/>
+ <sequenceFlow id="_10-_11" tns:priority="1" sourceRef="_10"
targetRef="_11"/>
+ <sequenceFlow id="_11-_13" tns:priority="1" sourceRef="_11"
targetRef="_13"/>
+ </process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_Process_1"
bpmnElement="InclusiveGatewayWithChainedXorSplitsInLoop">
+ <bpmndi:BPMNShape id="BPMNShape_1" bpmnElement="_1">
+ <dc:Bounds height="48.0" width="48.0" x="30.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_2" bpmnElement="_2">
+ <dc:Bounds height="48.0" width="48.0" x="130.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_3" bpmnElement="_3">
+ <dc:Bounds height="48.0" width="100.0" x="300.0" y="60.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_4" bpmnElement="_4">
+ <dc:Bounds height="48.0" width="48.0" x="230.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_5" bpmnElement="_5">
+ <dc:Bounds height="48.0" width="48.0" x="320.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_12" bpmnElement="_12">
+ <dc:Bounds height="48.0" width="48.0" x="320.0" y="400.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_6" bpmnElement="_6">
+ <dc:Bounds height="48.0" width="100.0" x="420.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_7" bpmnElement="_7">
+ <dc:Bounds height="48.0" width="48.0" x="570.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_8" bpmnElement="_8">
+ <dc:Bounds height="48.0" width="100.0" x="420.0" y="400.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_10" bpmnElement="_10">
+ <dc:Bounds height="48.0" width="48.0" x="700.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_11" bpmnElement="_11">
+ <dc:Bounds height="48.0" width="100.0" x="800.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_13" bpmnElement="_13">
+ <dc:Bounds height="48.0" width="48.0" x="950.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="BPMNEdge_1" bpmnElement="_1-_2">
+ <di:waypoint xsi:type="dc:Point" x="78.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="130.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_2" bpmnElement="_2-_3">
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="177.0"/>
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="300.0" y="84.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_3" bpmnElement="_2-_4">
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="225.0"/>
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="230.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_4" bpmnElement="_3-_10">
+ <di:waypoint xsi:type="dc:Point" x="400.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="177.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_5" bpmnElement="_4-_5">
+ <di:waypoint xsi:type="dc:Point" x="278.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="320.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_6" bpmnElement="_5-_6">
+ <di:waypoint xsi:type="dc:Point" x="368.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="420.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_7" bpmnElement="_5-_12">
+ <di:waypoint xsi:type="dc:Point" x="344.0" y="348.0"/>
+ <di:waypoint xsi:type="dc:Point" x="344.0" y="400.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_8" bpmnElement="_6-_7">
+ <di:waypoint xsi:type="dc:Point" x="520.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="570.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_9" bpmnElement="_7-_8">
+ <di:waypoint xsi:type="dc:Point" x="594.0" y="348.0"/>
+ <di:waypoint xsi:type="dc:Point" x="594.0" y="424.0"/>
+ <di:waypoint xsi:type="dc:Point" x="520.0" y="424.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_10" bpmnElement="_7-_10">
+ <di:waypoint xsi:type="dc:Point" x="618.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="225.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_11" bpmnElement="_8-_4">
+ <di:waypoint xsi:type="dc:Point" x="420.0" y="424.0"/>
+ <di:waypoint xsi:type="dc:Point" x="254.0" y="424.0"/>
+ <di:waypoint xsi:type="dc:Point" x="254.0" y="348.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_12" bpmnElement="_10-_11">
+ <di:waypoint xsi:type="dc:Point" x="748.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="800.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_13" bpmnElement="_11-_13">
+ <di:waypoint xsi:type="dc:Point" x="900.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="950.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</definitions>
diff --git
a/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithXorOnlyCycle.bpmn2
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithXorOnlyCycle.bpmn2
new file mode 100644
index 00000000000..573c138bdea
--- /dev/null
+++
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveGatewayWithXorOnlyCycle.bpmn2
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!--
+ An inclusive split starts "TaskA" and "TaskB". "TaskB" is followed by two
directly connected exclusive splits
+ that form a cycle without any activity in between, so the reachability check
of the inclusive join must
+ not follow the cycle endlessly.
+ Multiple incoming connections to a split are only allowed with
jbpm.enable.multi.con.
+-->
+<definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
id="Definition" expressionLanguage="http://www.mvel.org/2.0"
targetNamespace="http://www.jboss.org/dr [...]
+ <process id="InclusiveGatewayWithXorOnlyCycle" tns:version="1"
tns:packageName="org.jbpm.bpmn2.flow" tns:adHoc="false"
name="InclusiveGatewayWithXorOnlyCycle" isExecutable="true"
processType="Private">
+ <extensionElements>
+ <tns:metaData name="jbpm.enable.multi.con">
+ <tns:metaValue>true</tns:metaValue>
+ </tns:metaData>
+ </extensionElements>
+ <startEvent id="_1" name="Start">
+ <outgoing>_1-_2</outgoing>
+ </startEvent>
+ <inclusiveGateway id="_2" name="OR diverging" gatewayDirection="Diverging">
+ <incoming>_1-_2</incoming>
+ <outgoing>_2-_3</outgoing>
+ <outgoing>_2-_4</outgoing>
+ </inclusiveGateway>
+ <task id="_3" tns:taskName="taskA" name="TaskA">
+ <incoming>_2-_3</incoming>
+ <outgoing>_3-_10</outgoing>
+ </task>
+ <task id="_4" tns:taskName="taskB" name="TaskB">
+ <incoming>_2-_4</incoming>
+ <outgoing>_4-_5</outgoing>
+ </task>
+ <exclusiveGateway id="_5" name="XOR 1" gatewayDirection="Diverging"
default="_5-_10">
+ <incoming>_4-_5</incoming>
+ <incoming>_6-_5</incoming>
+ <outgoing>_5-_6</outgoing>
+ <outgoing>_5-_10</outgoing>
+ </exclusiveGateway>
+ <exclusiveGateway id="_6" name="XOR 2" gatewayDirection="Diverging"
default="_6-_10">
+ <incoming>_5-_6</incoming>
+ <outgoing>_6-_5</outgoing>
+ <outgoing>_6-_10</outgoing>
+ </exclusiveGateway>
+ <inclusiveGateway id="_10" name="OR converging"
gatewayDirection="Converging">
+ <incoming>_3-_10</incoming>
+ <incoming>_5-_10</incoming>
+ <incoming>_6-_10</incoming>
+ <outgoing>_10-_11</outgoing>
+ </inclusiveGateway>
+ <task id="_11" tns:taskName="afterJoin" name="AfterJoinTask">
+ <incoming>_10-_11</incoming>
+ <outgoing>_11-_13</outgoing>
+ </task>
+ <endEvent id="_13" name="End">
+ <incoming>_11-_13</incoming>
+ </endEvent>
+ <sequenceFlow id="_1-_2" tns:priority="1" sourceRef="_1" targetRef="_2"/>
+ <sequenceFlow id="_2-_3" tns:priority="1" sourceRef="_2" targetRef="_3">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_2-_4" tns:priority="1" sourceRef="_2" targetRef="_4">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_3-_10" tns:priority="1" sourceRef="_3" targetRef="_10"/>
+ <sequenceFlow id="_4-_5" tns:priority="1" sourceRef="_4" targetRef="_5"/>
+ <sequenceFlow id="_5-_6" tns:priority="1" sourceRef="_5" targetRef="_6">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return false;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_5-_10" tns:priority="2" sourceRef="_5" targetRef="_10"/>
+ <sequenceFlow id="_6-_5" tns:priority="1" sourceRef="_6" targetRef="_5">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return false;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_6-_10" tns:priority="2" sourceRef="_6" targetRef="_10"/>
+ <sequenceFlow id="_10-_11" tns:priority="1" sourceRef="_10"
targetRef="_11"/>
+ <sequenceFlow id="_11-_13" tns:priority="1" sourceRef="_11"
targetRef="_13"/>
+ </process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_Process_1"
bpmnElement="InclusiveGatewayWithXorOnlyCycle">
+ <bpmndi:BPMNShape id="BPMNShape_1" bpmnElement="_1">
+ <dc:Bounds height="48.0" width="48.0" x="30.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_2" bpmnElement="_2">
+ <dc:Bounds height="48.0" width="48.0" x="130.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_3" bpmnElement="_3">
+ <dc:Bounds height="48.0" width="100.0" x="300.0" y="60.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_4" bpmnElement="_4">
+ <dc:Bounds height="48.0" width="100.0" x="230.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_5" bpmnElement="_5">
+ <dc:Bounds height="48.0" width="48.0" x="380.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_6" bpmnElement="_6">
+ <dc:Bounds height="48.0" width="48.0" x="500.0" y="300.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_7" bpmnElement="_10">
+ <dc:Bounds height="48.0" width="48.0" x="700.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_8" bpmnElement="_11">
+ <dc:Bounds height="48.0" width="100.0" x="800.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BPMNShape_9" bpmnElement="_13">
+ <dc:Bounds height="48.0" width="48.0" x="950.0" y="177.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="BPMNEdge_1" bpmnElement="_1-_2">
+ <di:waypoint xsi:type="dc:Point" x="78.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="130.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_2" bpmnElement="_2-_3">
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="177.0"/>
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="300.0" y="84.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_3" bpmnElement="_2-_4">
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="225.0"/>
+ <di:waypoint xsi:type="dc:Point" x="154.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="230.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_4" bpmnElement="_3-_10">
+ <di:waypoint xsi:type="dc:Point" x="400.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="84.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="177.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_5" bpmnElement="_4-_5">
+ <di:waypoint xsi:type="dc:Point" x="330.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="380.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_6" bpmnElement="_5-_6">
+ <di:waypoint xsi:type="dc:Point" x="428.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="500.0" y="324.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_7" bpmnElement="_5-_10">
+ <di:waypoint xsi:type="dc:Point" x="404.0" y="300.0"/>
+ <di:waypoint xsi:type="dc:Point" x="404.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="700.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_8" bpmnElement="_6-_5">
+ <di:waypoint xsi:type="dc:Point" x="524.0" y="348.0"/>
+ <di:waypoint xsi:type="dc:Point" x="524.0" y="400.0"/>
+ <di:waypoint xsi:type="dc:Point" x="404.0" y="400.0"/>
+ <di:waypoint xsi:type="dc:Point" x="404.0" y="348.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_9" bpmnElement="_6-_10">
+ <di:waypoint xsi:type="dc:Point" x="548.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="324.0"/>
+ <di:waypoint xsi:type="dc:Point" x="724.0" y="225.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_10" bpmnElement="_10-_11">
+ <di:waypoint xsi:type="dc:Point" x="748.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="800.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="BPMNEdge_11" bpmnElement="_11-_13">
+ <di:waypoint xsi:type="dc:Point" x="900.0" y="201.0"/>
+ <di:waypoint xsi:type="dc:Point" x="950.0" y="201.0"/>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</definitions>
diff --git
a/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveJoinWithLoopIterations.bpmn2
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveJoinWithLoopIterations.bpmn2
new file mode 100644
index 00000000000..ad1c73600f0
--- /dev/null
+++
b/kogito-jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveJoinWithLoopIterations.bpmn2
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!--
+ Simplified version of a real world process:
+
+ - an inclusive split starts two independent reviews: "FA Review" and a "QS
Review" loop
+ - QS Review is followed by an exclusive split: pending (-> notification +
"Request Clarification" and back
+ to QS Review), or approved (-> inclusive join)
+ - FA Review goes straight to the inclusive join
+ - the notification branches dead-end in an end event
+
+ The loop is executed twice (variable "rounds"), so "Request Clarification"
of the second round is an
+ active node instance of a higher loop level than the inclusive join when "FA
Review" arrives at the join.
+-->
+<definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
id="Definition" expressionLanguage="http://www.mvel.org/2.0"
targetNamespace="http://www.jboss.org/dr [...]
+ <itemDefinition id="_roundsItem" structureRef="Integer"/>
+ <process id="InclusiveJoinWithLoopIterations" tns:version="1"
tns:packageName="org.jbpm.bpmn2.flow" tns:adHoc="false"
name="InclusiveJoinWithLoopIterations" isExecutable="true"
processType="Private">
+ <property id="rounds" itemSubjectRef="_roundsItem"/>
+ <startEvent id="_start" name="Start">
+ <outgoing>_start-_orSplit</outgoing>
+ </startEvent>
+ <inclusiveGateway id="_orSplit" name="OR split"
gatewayDirection="Diverging">
+ <incoming>_start-_orSplit</incoming>
+ <outgoing>_orSplit-_fa</outgoing>
+ <outgoing>_orSplit-_xorJoin</outgoing>
+ </inclusiveGateway>
+ <!-- FA branch -->
+ <task id="_fa" tns:taskName="faReview" name="FA Review">
+ <incoming>_orSplit-_fa</incoming>
+ <outgoing>_fa-_orJoin</outgoing>
+ </task>
+ <!-- QS branch (loop) -->
+ <exclusiveGateway id="_xorJoin" name="XOR join"
gatewayDirection="Converging">
+ <incoming>_orSplit-_xorJoin</incoming>
+ <incoming>_rc-_xorJoin</incoming>
+ <outgoing>_xorJoin-_andSplit1</outgoing>
+ </exclusiveGateway>
+ <parallelGateway id="_andSplit1" name="AND split (QS)"
gatewayDirection="Diverging">
+ <incoming>_xorJoin-_andSplit1</incoming>
+ <outgoing>_andSplit1-_notifQs</outgoing>
+ <outgoing>_andSplit1-_qs</outgoing>
+ </parallelGateway>
+ <task id="_notifQs" tns:taskName="notification" name="QS Notification">
+ <incoming>_andSplit1-_notifQs</incoming>
+ <outgoing>_notifQs-_endQs</outgoing>
+ </task>
+ <endEvent id="_endQs" name="End QS notification">
+ <incoming>_notifQs-_endQs</incoming>
+ </endEvent>
+ <task id="_qs" tns:taskName="qsReview" name="QS Review">
+ <incoming>_andSplit1-_qs</incoming>
+ <outgoing>_qs-_xorSplit</outgoing>
+ </task>
+ <exclusiveGateway id="_xorSplit" name="XOR split (QS result)"
gatewayDirection="Diverging" default="_xorSplit-_orJoin">
+ <incoming>_qs-_xorSplit</incoming>
+ <outgoing>_xorSplit-_andSplit2</outgoing>
+ <outgoing>_xorSplit-_orJoin</outgoing>
+ </exclusiveGateway>
+ <parallelGateway id="_andSplit2" name="AND split (pending)"
gatewayDirection="Diverging">
+ <incoming>_xorSplit-_andSplit2</incoming>
+ <outgoing>_andSplit2-_notifRc</outgoing>
+ <outgoing>_andSplit2-_rc</outgoing>
+ </parallelGateway>
+ <task id="_notifRc" tns:taskName="notification" name="RC Notification">
+ <incoming>_andSplit2-_notifRc</incoming>
+ <outgoing>_notifRc-_endRc</outgoing>
+ </task>
+ <endEvent id="_endRc" name="End RC notification">
+ <incoming>_notifRc-_endRc</incoming>
+ </endEvent>
+ <task id="_rc" tns:taskName="requestClarification" name="Request
Clarification">
+ <extensionElements>
+ <tns:onExit-script scriptFormat="http://www.java.com/java">
+ <tns:script>kcontext.setVariable("rounds", rounds +
1);</tns:script>
+ </tns:onExit-script>
+ </extensionElements>
+ <incoming>_andSplit2-_rc</incoming>
+ <outgoing>_rc-_xorJoin</outgoing>
+ </task>
+ <!-- Join and rest of the process -->
+ <inclusiveGateway id="_orJoin" name="OR join"
gatewayDirection="Converging">
+ <incoming>_fa-_orJoin</incoming>
+ <incoming>_xorSplit-_orJoin</incoming>
+ <outgoing>_orJoin-_after</outgoing>
+ </inclusiveGateway>
+ <task id="_after" tns:taskName="afterJoin" name="AfterJoinTask">
+ <incoming>_orJoin-_after</incoming>
+ <outgoing>_after-_end</outgoing>
+ </task>
+ <endEvent id="_end" name="End">
+ <incoming>_after-_end</incoming>
+ </endEvent>
+ <sequenceFlow id="_start-_orSplit" tns:priority="1" sourceRef="_start"
targetRef="_orSplit"/>
+ <sequenceFlow id="_orSplit-_fa" tns:priority="1" sourceRef="_orSplit"
targetRef="_fa">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_orSplit-_xorJoin" tns:priority="1" sourceRef="_orSplit"
targetRef="_xorJoin">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return true;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_fa-_orJoin" tns:priority="1" sourceRef="_fa"
targetRef="_orJoin"/>
+ <sequenceFlow id="_xorJoin-_andSplit1" tns:priority="1"
sourceRef="_xorJoin" targetRef="_andSplit1"/>
+ <sequenceFlow id="_andSplit1-_notifQs" tns:priority="1"
sourceRef="_andSplit1" targetRef="_notifQs"/>
+ <sequenceFlow id="_andSplit1-_qs" tns:priority="1" sourceRef="_andSplit1"
targetRef="_qs"/>
+ <sequenceFlow id="_notifQs-_endQs" tns:priority="1" sourceRef="_notifQs"
targetRef="_endQs"/>
+ <sequenceFlow id="_qs-_xorSplit" tns:priority="1" sourceRef="_qs"
targetRef="_xorSplit"/>
+ <sequenceFlow id="_xorSplit-_andSplit2" tns:priority="1" name="pending"
sourceRef="_xorSplit" targetRef="_andSplit2">
+ <conditionExpression xsi:type="tFormalExpression"
language="http://www.java.com/java">return rounds < 2;</conditionExpression>
+ </sequenceFlow>
+ <sequenceFlow id="_xorSplit-_orJoin" tns:priority="2" name="approved"
sourceRef="_xorSplit" targetRef="_orJoin"/>
+ <sequenceFlow id="_andSplit2-_notifRc" tns:priority="1"
sourceRef="_andSplit2" targetRef="_notifRc"/>
+ <sequenceFlow id="_andSplit2-_rc" tns:priority="1" sourceRef="_andSplit2"
targetRef="_rc"/>
+ <sequenceFlow id="_notifRc-_endRc" tns:priority="1" sourceRef="_notifRc"
targetRef="_endRc"/>
+ <sequenceFlow id="_rc-_xorJoin" tns:priority="1" sourceRef="_rc"
targetRef="_xorJoin"/>
+ <sequenceFlow id="_orJoin-_after" tns:priority="1" sourceRef="_orJoin"
targetRef="_after"/>
+ <sequenceFlow id="_after-_end" tns:priority="1" sourceRef="_after"
targetRef="_end"/>
+ </process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_Process_1"
bpmnElement="InclusiveJoinWithLoopIterations">
+ <bpmndi:BPMNShape id="S_start" bpmnElement="_start"><dc:Bounds
height="48.0" width="48.0" x="30.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_orSplit" bpmnElement="_orSplit"><dc:Bounds
height="48.0" width="48.0" x="120.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_fa" bpmnElement="_fa"><dc:Bounds height="48.0"
width="100.0" x="300.0" y="40.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_xorJoin" bpmnElement="_xorJoin"><dc:Bounds
height="48.0" width="48.0" x="220.0" y="300.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_andSplit1" bpmnElement="_andSplit1"><dc:Bounds
height="48.0" width="48.0" x="310.0" y="300.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_notifQs" bpmnElement="_notifQs"><dc:Bounds
height="48.0" width="100.0" x="400.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_endQs" bpmnElement="_endQs"><dc:Bounds
height="48.0" width="48.0" x="550.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_qs" bpmnElement="_qs"><dc:Bounds height="48.0"
width="100.0" x="400.0" y="300.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_xorSplit" bpmnElement="_xorSplit"><dc:Bounds
height="48.0" width="48.0" x="550.0" y="300.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_andSplit2" bpmnElement="_andSplit2"><dc:Bounds
height="48.0" width="48.0" x="550.0" y="400.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_notifRc" bpmnElement="_notifRc"><dc:Bounds
height="48.0" width="100.0" x="640.0" y="480.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_endRc" bpmnElement="_endRc"><dc:Bounds
height="48.0" width="48.0" x="790.0" y="480.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_rc" bpmnElement="_rc"><dc:Bounds height="48.0"
width="100.0" x="400.0" y="400.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_orJoin" bpmnElement="_orJoin"><dc:Bounds
height="48.0" width="48.0" x="700.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_after" bpmnElement="_after"><dc:Bounds
height="48.0" width="100.0" x="800.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="S_end" bpmnElement="_end"><dc:Bounds height="48.0"
width="48.0" x="950.0" y="200.0"/></bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="E1" bpmnElement="_start-_orSplit"><di:waypoint
xsi:type="dc:Point" x="78.0" y="224.0"/><di:waypoint xsi:type="dc:Point"
x="120.0" y="224.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E2" bpmnElement="_orSplit-_fa"><di:waypoint
xsi:type="dc:Point" x="144.0" y="200.0"/><di:waypoint xsi:type="dc:Point"
x="144.0" y="64.0"/><di:waypoint xsi:type="dc:Point" x="300.0"
y="64.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E3" bpmnElement="_orSplit-_xorJoin"><di:waypoint
xsi:type="dc:Point" x="144.0" y="248.0"/><di:waypoint xsi:type="dc:Point"
x="144.0" y="324.0"/><di:waypoint xsi:type="dc:Point" x="220.0"
y="324.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E4" bpmnElement="_fa-_orJoin"><di:waypoint
xsi:type="dc:Point" x="400.0" y="64.0"/><di:waypoint xsi:type="dc:Point"
x="724.0" y="64.0"/><di:waypoint xsi:type="dc:Point" x="724.0"
y="200.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E5" bpmnElement="_xorJoin-_andSplit1"><di:waypoint
xsi:type="dc:Point" x="268.0" y="324.0"/><di:waypoint xsi:type="dc:Point"
x="310.0" y="324.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E6" bpmnElement="_andSplit1-_notifQs"><di:waypoint
xsi:type="dc:Point" x="334.0" y="300.0"/><di:waypoint xsi:type="dc:Point"
x="334.0" y="224.0"/><di:waypoint xsi:type="dc:Point" x="400.0"
y="224.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E7" bpmnElement="_andSplit1-_qs"><di:waypoint
xsi:type="dc:Point" x="358.0" y="324.0"/><di:waypoint xsi:type="dc:Point"
x="400.0" y="324.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E8" bpmnElement="_notifQs-_endQs"><di:waypoint
xsi:type="dc:Point" x="500.0" y="224.0"/><di:waypoint xsi:type="dc:Point"
x="550.0" y="224.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E9" bpmnElement="_qs-_xorSplit"><di:waypoint
xsi:type="dc:Point" x="500.0" y="324.0"/><di:waypoint xsi:type="dc:Point"
x="550.0" y="324.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E10"
bpmnElement="_xorSplit-_andSplit2"><di:waypoint xsi:type="dc:Point" x="574.0"
y="348.0"/><di:waypoint xsi:type="dc:Point" x="574.0"
y="400.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E11" bpmnElement="_xorSplit-_orJoin"><di:waypoint
xsi:type="dc:Point" x="598.0" y="324.0"/><di:waypoint xsi:type="dc:Point"
x="724.0" y="324.0"/><di:waypoint xsi:type="dc:Point" x="724.0"
y="248.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E12" bpmnElement="_andSplit2-_notifRc"><di:waypoint
xsi:type="dc:Point" x="598.0" y="424.0"/><di:waypoint xsi:type="dc:Point"
x="620.0" y="424.0"/><di:waypoint xsi:type="dc:Point" x="620.0"
y="504.0"/><di:waypoint xsi:type="dc:Point" x="640.0"
y="504.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E13" bpmnElement="_andSplit2-_rc"><di:waypoint
xsi:type="dc:Point" x="550.0" y="424.0"/><di:waypoint xsi:type="dc:Point"
x="500.0" y="424.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E14" bpmnElement="_notifRc-_endRc"><di:waypoint
xsi:type="dc:Point" x="740.0" y="504.0"/><di:waypoint xsi:type="dc:Point"
x="790.0" y="504.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E15" bpmnElement="_rc-_xorJoin"><di:waypoint
xsi:type="dc:Point" x="400.0" y="424.0"/><di:waypoint xsi:type="dc:Point"
x="244.0" y="424.0"/><di:waypoint xsi:type="dc:Point" x="244.0"
y="348.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E16" bpmnElement="_orJoin-_after"><di:waypoint
xsi:type="dc:Point" x="748.0" y="224.0"/><di:waypoint xsi:type="dc:Point"
x="800.0" y="224.0"/></bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="E17" bpmnElement="_after-_end"><di:waypoint
xsi:type="dc:Point" x="900.0" y="224.0"/><di:waypoint xsi:type="dc:Point"
x="950.0" y="224.0"/></bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</definitions>
diff --git a/kogito-jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
b/kogito-jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
index 52a99b74982..000e9e3fdb7 100755
--- a/kogito-jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
+++ b/kogito-jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
@@ -50,6 +50,8 @@ import org.jbpm.bpmn2.flow.GatewayTestModel;
import org.jbpm.bpmn2.flow.GatewayTestProcess;
import org.jbpm.bpmn2.flow.InclusiveGatewayNestedModel;
import org.jbpm.bpmn2.flow.InclusiveGatewayNestedProcess;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithChainedXorSplitsInLoopModel;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithChainedXorSplitsInLoopProcess;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithDefaultModel;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithDefaultProcess;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithHumanTasksProcessModel;
@@ -58,6 +60,10 @@ import
org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideModel;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideProcess;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideSubprocessModel;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideSubprocessProcess;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithXorOnlyCycleModel;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithXorOnlyCycleProcess;
+import org.jbpm.bpmn2.flow.InclusiveJoinWithLoopIterationsModel;
+import org.jbpm.bpmn2.flow.InclusiveJoinWithLoopIterationsProcess;
import org.jbpm.bpmn2.flow.InclusiveNestedInParallelNestedInExclusiveModel;
import org.jbpm.bpmn2.flow.InclusiveNestedInParallelNestedInExclusiveProcess;
import org.jbpm.bpmn2.flow.InclusiveSplitAndJoinEmbeddedModel;
@@ -909,6 +915,123 @@ public class FlowTest extends JbpmBpmn2TestCase {
assertThat((int) nodeInstanceExecutionCounter.get("End")).isEqualTo(1);
}
+ @Test
+ public void testInclusiveJoinWaitsForLoopWithChainedXorSplits() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler taskA = new TestWorkItemHandler();
+ TestWorkItemHandler taskB1 = new TestWorkItemHandler();
+ TestWorkItemHandler taskB2 = new TestWorkItemHandler();
+ TestWorkItemHandler afterJoin = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "taskA", taskA);
+ ProcessTestHelper.registerHandler(app, "taskB1", taskB1);
+ ProcessTestHelper.registerHandler(app, "taskB2", taskB2);
+ ProcessTestHelper.registerHandler(app, "afterJoin", afterJoin);
+
+
org.kie.kogito.process.Process<InclusiveGatewayWithChainedXorSplitsInLoopModel>
definition = InclusiveGatewayWithChainedXorSplitsInLoopProcess.newProcess(app);
+ InclusiveGatewayWithChainedXorSplitsInLoopModel model =
definition.createModel();
+ model.setX(0);
+ ProcessInstance<InclusiveGatewayWithChainedXorSplitsInLoopModel>
processInstance = definition.createInstance(model);
+ processInstance.start();
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
+ KogitoWorkItem taskAWorkItem = taskA.getWorkItem();
+ assertThat(taskAWorkItem).isNotNull();
+
+ // B1 completes first and the exclusive split sends the token to B2
(loop)
+ processInstance.completeWorkItem(taskB1.getWorkItem().getStringId(),
null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
+ // completing A must not trigger the join since the loop token in B2
can still reach it
+ processInstance.completeWorkItem(taskAWorkItem.getStringId(), null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ assertThat(afterJoin.getWorkItem()).isNull();
+
+ // B2 completes, loops back to B1 which now proceeds to the join
+ processInstance.completeWorkItem(taskB2.getWorkItem().getStringId(),
null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ assertThat(afterJoin.getWorkItem()).isNull();
+ processInstance.completeWorkItem(taskB1.getWorkItem().getStringId(),
null);
+
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
processInstance.completeWorkItem(afterJoin.getWorkItem().getStringId(), null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+ }
+
+ @Test
+ public void testInclusiveJoinWithCycleOfDirectlyConnectedXorSplits() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler taskA = new TestWorkItemHandler();
+ TestWorkItemHandler taskB = new TestWorkItemHandler();
+ TestWorkItemHandler afterJoin = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "taskA", taskA);
+ ProcessTestHelper.registerHandler(app, "taskB", taskB);
+ ProcessTestHelper.registerHandler(app, "afterJoin", afterJoin);
+
+ org.kie.kogito.process.Process<InclusiveGatewayWithXorOnlyCycleModel>
definition = InclusiveGatewayWithXorOnlyCycleProcess.newProcess(app);
+ ProcessInstance<InclusiveGatewayWithXorOnlyCycleModel> processInstance
= definition.createInstance(definition.createModel());
+ processInstance.start();
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
+ // checking if TaskB can still reach the join must terminate although
the exclusive splits form a cycle
+ processInstance.completeWorkItem(taskA.getWorkItem().getStringId(),
null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ assertThat(afterJoin.getWorkItem()).isNull();
+
+ processInstance.completeWorkItem(taskB.getWorkItem().getStringId(),
null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
processInstance.completeWorkItem(afterJoin.getWorkItem().getStringId(), null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+ }
+
+ @Test
+ public void testInclusiveJoinWaitsForActiveNodeOfLaterLoopIteration() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler faReview = new TestWorkItemHandler();
+ TestWorkItemHandler qsReview = new TestWorkItemHandler();
+ TestWorkItemHandler requestClarification = new TestWorkItemHandler();
+ TestWorkItemHandler notification = new TestWorkItemHandler();
+ TestWorkItemHandler afterJoin = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "faReview", faReview);
+ ProcessTestHelper.registerHandler(app, "qsReview", qsReview);
+ ProcessTestHelper.registerHandler(app, "requestClarification",
requestClarification);
+ ProcessTestHelper.registerHandler(app, "notification", notification);
+ ProcessTestHelper.registerHandler(app, "afterJoin", afterJoin);
+
+ org.kie.kogito.process.Process<InclusiveJoinWithLoopIterationsModel>
definition = InclusiveJoinWithLoopIterationsProcess.newProcess(app);
+ InclusiveJoinWithLoopIterationsModel model = definition.createModel();
+ model.setRounds(0);
+ ProcessInstance<InclusiveJoinWithLoopIterationsModel> processInstance
= definition.createInstance(model);
+ processInstance.start();
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+
+ KogitoWorkItem faWorkItem = faReview.getWorkItem();
+ assertThat(faWorkItem).isNotNull();
+
+ // first round: QS Review requests a clarification which is answered
+ processInstance.completeWorkItem(qsReview.getWorkItem().getStringId(),
null);
+
processInstance.completeWorkItem(requestClarification.getWorkItem().getStringId(),
null);
+
+ // second round: QS Review requests a clarification again and it stays
pending
+ processInstance.completeWorkItem(qsReview.getWorkItem().getStringId(),
null);
+ KogitoWorkItem secondClarification =
requestClarification.getWorkItem();
+ assertThat(secondClarification).isNotNull();
+
+ // FA Review arrives at the join while the clarification of the second
round is still active
+ processInstance.completeWorkItem(faWorkItem.getStringId(), null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ assertThat(afterJoin.getWorkItem()).as("join must wait for the pending
clarification of the second round").isNull();
+
+ // clarification answered, QS Review is approved in the third round
and the join can proceed
+ processInstance.completeWorkItem(secondClarification.getStringId(),
null);
+ processInstance.completeWorkItem(qsReview.getWorkItem().getStringId(),
null);
+ KogitoWorkItem afterJoinWorkItem = afterJoin.getWorkItem();
+ assertThat(afterJoinWorkItem).isNotNull();
+
+ notification.getWorkItems().forEach(workItem ->
processInstance.completeWorkItem(workItem.getStringId(), null));
+ processInstance.completeWorkItem(afterJoinWorkItem.getStringId(),
null);
+
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+ }
+
@Test
public void testMultiInstanceLoopCharacteristicsProcessWithORGateway() {
Application app = ProcessTestHelper.newApplication();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]