Skip to content

Commit 5102694

Browse files
committed
Fix case / process instance ended invoked twice when undeploying deeply nested app
1 parent b42f851 commit 5102694

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteHistoricCaseInstanceCmd.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.flowable.cmmn.api.history.HistoricCaseInstance;
1919
import org.flowable.cmmn.engine.CmmnEngineConfiguration;
20+
import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity;
2021
import org.flowable.cmmn.engine.impl.util.CommandContextUtil;
2122
import org.flowable.common.engine.api.FlowableException;
2223
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
@@ -44,11 +45,16 @@ public Object execute(CommandContext commandContext) {
4445
}
4546
// Check if case instance is still running
4647
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
47-
HistoricCaseInstance instance = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findById(caseInstanceId);
48+
HistoricCaseInstanceEntity instance = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findById(caseInstanceId);
4849

4950
if (instance == null) {
5051
throw new FlowableObjectNotFoundException("No historic case instance found with id: " + caseInstanceId, HistoricCaseInstance.class);
5152
}
53+
if (instance.isDeleted()) {
54+
return null;
55+
}
56+
57+
5258
if (instance.getEndTime() == null) {
5359
throw new FlowableException("Case instance is still running, cannot delete " + instance);
5460
}

modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteHistoricProcessInstanceCmd.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.flowable.common.engine.impl.interceptor.CommandContext;
2323
import org.flowable.engine.compatibility.Flowable5CompatibilityHandler;
2424
import org.flowable.engine.history.HistoricProcessInstance;
25+
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
2526
import org.flowable.engine.impl.util.CommandContextUtil;
2627
import org.flowable.engine.impl.util.Flowable5Util;
2728

@@ -43,11 +44,14 @@ public Object execute(CommandContext commandContext) {
4344
throw new FlowableIllegalArgumentException("processInstanceId is null");
4445
}
4546
// Check if process instance is still running
46-
HistoricProcessInstance instance = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext).findById(processInstanceId);
47+
HistoricProcessInstanceEntity instance = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext).findById(processInstanceId);
4748

4849
if (instance == null) {
4950
throw new FlowableObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
5051
}
52+
if (instance.isDeleted()) {
53+
return null;
54+
}
5155
if (instance.getEndTime() == null) {
5256
throw new FlowableException("Process instance is still running, cannot delete " + instance);
5357
}

0 commit comments

Comments
 (0)