flowable / flowable/flowable-engine
EndEventParseHandler not setting correct error code for ErrorEndEventActivityBehavior
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 7h 8m
- Merged PRs (30d)
- 2
Description
**Describe the bug**
Error end events use the `errorRef` attribute as the error code, but they should be using the error code of the *error* pointed by the ref. What happens in the [EndEventParserHandler.executeParse](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EndEventParseHandler.java#L48-L58) method class at (snip):
```java
ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
if (StringUtils.isEmpty(errorCode)) {
LOGGER.warn("errorCode is required for an error event {}", endEvent.getId());
}
}
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
```
Is that the errorCode from the model's error map is not given to the assigned errorDefinition activity. So, `String errorCode` does contain the right error code, but it's not set to the ErrorEndEventActivity.
The behaviour seems to be a regression in Flowable 6. If we look at the code from [flowable5](https://github.com/flowable/flowable-engine/blob/master/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/EndEventParseHandler.java#L51-L60):
```java
org.flowable.bpmn.model.ErrorEventDefinition errorDefinition = (org.flowable.bpmn.model.ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
if (StringUtils.isEmpty(errorCode)) {
LOGGER.warn("errorCode is required for an error event {}", endEvent.getId());
}
endEventActivity.setProperty("type", "errorEndEvent");
errorDefinition.setErrorCode(errorCode);
}
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
```
On line 58 we see the errorCode being set to the errorDefinition. If we compare the code between escalation and error events, the behaviour in both was to assign the correct code to the created ActivityBehavior class.
**Expected behavior**
The error code of the created ErrorEndEvent should be the error code of the error pointed by the error definition referenced by the `errorRef` attribute, not the value of the `errorRef` itself.
**Additional context**
flowable-engine 6.6.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.