MultiInstance Activity parallel bug - ClassCastException

Hi,

I try to use multiInstance loop activity with sequential = false but I got an exception at line:

int nrOfCompletedInstances = getLoopVariable(execution, NUMBER_OF_COMPLETED_INSTANCES) + 1;

as NUMBER_OF_COMPLETED_INSTANCES is of type ParallelMultiInstanceLoopVariable and not integer.

Is there any fix or workaround to solve this issue?

Regards,

Hi @rpochet,

can you share an example model for which you have the issue and the stacktrace of the exection? Which version are you using?

Valentin

Flowable 7.0.1

BPMN

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<semantic:definitions xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:semantic="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:arisebpmn="http://www.softwareag.com/aris/ebpmn" xmlns:i18n="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:aris="http://www.softwareag.com/aris/attributes" id="Definitions_ID-ecefe4b1-614f-11ef-505b-005056b0993f" name="multiloop" targetNamespace="http://www.softwareag.com/aris/bpmn2" exporter="ARIS" exporterVersion="10.0.0.1609462" xml:lang="en">
    <semantic:process name="multiloop:v1" id="Process_ID-ecefe4b1-614f-11ef-505b-005056b0993f">
        <semantic:extensionElements>
            <aris:attributes>
                <aris:attribute name="AT_ID" value="STD.11535940"/>
            </aris:attributes>
        </semantic:extensionElements>
        <semantic:startEvent name="Start event" id="ID-f338a0a0-614f-11ef-505b-005056b0993f">
            <semantic:extensionElements>
                <aris:attributes>
                    <aris:attribute name="AT_ID" value="STD.11535960"/>
                </aris:attributes>
            </semantic:extensionElements>
            <semantic:outgoing>ID-f338eec3-614f-11ef-505b-005056b0993f</semantic:outgoing>
        </semantic:startEvent>
        <semantic:serviceTask name="Task" id="ID-f338eec1-614f-11ef-505b-005056b0993f">
            <semantic:extensionElements>
                <aris:attributes>
                    <aris:attribute name="AT_ID" value="STD.11535961"/>
                </aris:attributes>
            </semantic:extensionElements>
            <semantic:incoming>ID-f338eec3-614f-11ef-505b-005056b0993f</semantic:incoming>
            <semantic:outgoing>ID-f338eec6-614f-11ef-505b-005056b0993f</semantic:outgoing>
            <semantic:multiInstanceLoopCharacteristics isSequential="false">
                <semantic:loopCardinality>5</semantic:loopCardinality>
            </semantic:multiInstanceLoopCharacteristics>
        </semantic:serviceTask>
        <semantic:endEvent name="End event" id="ID-f338eec4-614f-11ef-505b-005056b0993f">
            <semantic:extensionElements>
                <aris:attributes>
                    <aris:attribute name="AT_ID" value="STD.11535963"/>
                </aris:attributes>
            </semantic:extensionElements>
            <semantic:incoming>ID-f338eec6-614f-11ef-505b-005056b0993f</semantic:incoming>
        </semantic:endEvent>
        <semantic:sequenceFlow sourceRef="ID-f338a0a0-614f-11ef-505b-005056b0993f" targetRef="ID-f338eec1-614f-11ef-505b-005056b0993f" id="ID-f338eec3-614f-11ef-505b-005056b0993f">
            <semantic:extensionElements>
                <aris:attributes>
                    <aris:attribute name="AT_ID" value="STD.11535962"/>
                </aris:attributes>
            </semantic:extensionElements>
        </semantic:sequenceFlow>
        <semantic:sequenceFlow sourceRef="ID-f338eec1-614f-11ef-505b-005056b0993f" targetRef="ID-f338eec4-614f-11ef-505b-005056b0993f" id="ID-f338eec6-614f-11ef-505b-005056b0993f">
            <semantic:extensionElements>
                <aris:attributes>
                    <aris:attribute name="AT_ID" value="STD.11535964"/>
                </aris:attributes>
            </semantic:extensionElements>
        </semantic:sequenceFlow>
    </semantic:process>
    <bpmndi:BPMNDiagram name="multiloop" resolution="72.0" id="ID-ecefe4b1-614f-11ef-505b-005056b0993f">
        <bpmndi:BPMNPlane bpmnElement="Process_ID-ecefe4b1-614f-11ef-505b-005056b0993f" id="Plane_ID-ecefe4b1-614f-11ef-505b-005056b0993f">
            <bpmndi:BPMNShape bpmnElement="ID-f338a0a0-614f-11ef-505b-005056b0993f" id="Shape_ID-f338a0a0-614f-11ef-505b-005056b0993f" color:background-color="#ffffff" color:border-color="#72ab16">
                <dc:Bounds x="138.61" y="181.13" width="34.58" height="34.58"/>
                <bpmndi:BPMNLabel labelStyle="ArisFontStyleSheet_0_d7b815f4-04df-4971-8f01-03fe21c67159" color:color="#000000">
                    <dc:Bounds x="132.66" y="218.55" width="46.77" height="11.34"/>
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="ID-f338eec1-614f-11ef-505b-005056b0993f" id="Shape_ID-f338eec1-614f-11ef-505b-005056b0993f" color:background-color="#ffffff" color:border-color="#00a2ce">
                <dc:Bounds x="259.65" y="167.24" width="104.31" height="62.36"/>
                <bpmndi:BPMNLabel labelStyle="ArisFontStyleSheet_0_d7b815f4-04df-4971-8f01-03fe21c67159" color:color="#000000">
                    <dc:Bounds x="301.32" y="200.69" width="21.26" height="11.34"/>
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNEdge bpmnElement="ID-f338eec3-614f-11ef-505b-005056b0993f" id="Edge_ID-f338eec3-614f-11ef-505b-005056b0993f" color:border-color="#666666">
                <di:waypoint x="173.2" y="198.43"/>
                <di:waypoint x="259.65" y="198.43"/>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNShape bpmnElement="ID-f338eec4-614f-11ef-505b-005056b0993f" id="Shape_ID-f338eec4-614f-11ef-505b-005056b0993f" color:background-color="#ffffff" color:border-color="#fd6767">
                <dc:Bounds x="450.43" y="181.98" width="32.88" height="32.88"/>
                <bpmndi:BPMNLabel labelStyle="ArisFontStyleSheet_0_d7b815f4-04df-4971-8f01-03fe21c67159" color:color="#000000">
                    <dc:Bounds x="445.32" y="217.7" width="43.37" height="11.34"/>
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNEdge bpmnElement="ID-f338eec6-614f-11ef-505b-005056b0993f" id="Edge_ID-f338eec6-614f-11ef-505b-005056b0993f" color:border-color="#666666">
                <di:waypoint x="363.97" y="198.43"/>
                <di:waypoint x="450.43" y="198.43"/>
            </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
        <bpmndi:BPMNLabelStyle id="ArisFontStyleSheet_0_d7b815f4-04df-4971-8f01-03fe21c67159">
            <dc:Font name="Arial" size="11.0" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
        </bpmndi:BPMNLabelStyle>
    </bpmndi:BPMNDiagram>
</semantic:definitions>

Error

2024-08-23T13:09:49.818Z ERROR 23878 --- [provider] [         task-5] o.f.c.e.impl.interceptor.CommandContext  : PDID=512742f8-6150-11ef-8b4c-028dfdf55f05 EID=cae6dc9c-6150-11ef-8f10-028dfdf55f05 PIID=cab3225d-6150-11ef-8f10-028dfdf55f05 BK=multiloop:v1 Error while closing command context

java.lang.ClassCastException: class org.flowable.engine.impl.variable.ParallelMultiInstanceLoopVariable cannot be cast to class java.lang.Integer (org.flowable.engine.impl.variable.ParallelMultiInstanceLoopVariable is in unnamed module of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')
	at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.getLoopVariable(MultiInstanceActivityBehavior.java:408) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.internalLeave(ParallelMultiInstanceBehavior.java:187) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:174) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:60) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior.execute(ServiceTaskExpressionActivityBehavior.java:104) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.execute(MultiInstanceActivityBehavior.java:163) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:298) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeMultiInstanceSynchronous(ContinueProcessOperation.java:219) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:122) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:88) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.lambda$new$0(AbstractEngineConfiguration.java:196) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:166) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:121) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:77) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26) ~[flowable-engine-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:105) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:57) ~[flowable-spring-common-7.0.1.jar:7.0.1]
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-6.1.11.jar:6.1.11]
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:57) ~[flowable-spring-common-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51) ~[flowable-engine-common-7.0.1.jar:7.0.1]
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:117) ~[flowable-job-service-7.0.1.jar:7.0.1]
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.runInternally(ExecuteAsyncRunnable.java:105) ~[flowable-job-service-7.0.1.jar:7.0.1]
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:80) ~[flowable-job-service-7.0.1.jar:7.0.1]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na]