cancel
Showing results for 
Search instead for 
Did you mean: 

Catching BPMNError does not end throwing activiti

patryan
Champ in-the-making
Champ in-the-making
Hi
- I have a script task in a sub process which throws a BpmnError, and an ErrorBoundaryEvent to catch it (activiti v 5.18.0)_

When I run the process I see that the script task is not ended:


select ACT_ID_  from ACT_HI_ACTINST where end_time_ is  null
gives

ACT_ID_
———–
scripttask1

- if I run it three times I get three of them - so it is effectively a leak

I would have though the catching event would have ended the throwing activity. Or do I need to do this in a finally clause?

Here is the test process definition

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <subProcess id="subprocess1" name="Sub Process">
      <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
        <script>throw new org.activiti.engine.delegate.BpmnError("test")</script>
      </scriptTask>
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <sequenceFlow id="flow2" sourceRef="startevent2" targetRef="scripttask1"></sequenceFlow>
      <sequenceFlow id="flow3" sourceRef="scripttask1" targetRef="endevent2"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="subprocess1" targetRef="endevent1"></sequenceFlow>
    <boundaryEvent id="boundaryerror1" name="Error" attachedToRef="subprocess1">
      <errorEventDefinition></errorEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow5" sourceRef="boundaryerror1" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>


5 REPLIES 5

patryan
Champ in-the-making
Champ in-the-making
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <subProcess id="subprocess1" name="Sub Process">
      <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
        <script>throw new org.activiti.engine.delegate.BpmnError("test")</script>
      </scriptTask>
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <sequenceFlow id="flow2" sourceRef="startevent2" targetRef="scripttask1"></sequenceFlow>
      <sequenceFlow id="flow3" sourceRef="scripttask1" targetRef="endevent2"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="subprocess1" targetRef="endevent1"></sequenceFlow>
    <boundaryEvent id="boundaryerror1" name="Error" attachedToRef="subprocess1">
      <errorEventDefinition></errorEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow5" sourceRef="boundaryerror1" targetRef="endevent1"></sequenceFlow>
  </process>
  </definitions>

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Pat,

check activiti source code. There are many examples of BPMN error events.
e.g.
org.activiti.spring.test.servicetask.BoundaryErrorEventSpringTest
org.activiti.engine.test.bpmn.event.error.BoundaryErrorEventTest
….

Regards
Martin

Thanks Martin
- I ran testCatchErrorThrownByJavaDelegateOnEmbeddedSubProcess.bpmn  from Activiti Explorer and completed the escalated user task, then ran the query
"select ACT_ID_  from ACT_HI_ACTINST where end_time_ is  null"

it returned "serviceTask"
As per my original post, it seems that a when a task in a sub-process throws a  BPMNError which is caught  by a BoundaryErrorEvent on the subprocess, the throwing task is not ended, resulting in a leak.


jbarrez
Star Contributor
Star Contributor
That indeed seems wrong. I can reproduce.
Looking into it. Will post an update once I know more.