You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by mw...@apache.org on 2024/09/24 18:05:04 UTC
(incubator-kie-kogito-runtimes) branch main updated: Dispose KieSession after rules execution when using ruleFlowGroup (#3678)
This is an automated email from the ASF dual-hosted git repository.
mweiler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 5810447b0c Dispose KieSession after rules execution when using ruleFlowGroup (#3678)
5810447b0c is described below
commit 5810447b0cbb20e036a9a6f3fec07faa929f2231
Author: Martin Weiler <mw...@ibm.com>
AuthorDate: Tue Sep 24 12:04:59 2024 -0600
Dispose KieSession after rules execution when using ruleFlowGroup (#3678)
* Dispose KieSession after rules execution when using ruleFlowGroup
---
.../org/jbpm/bpmn2/rule/RuleFlowGroupRuleTypeEngineImpl.java | 3 +++
jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/RuleFlowGroupRuleTypeEngineImpl.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/RuleFlowGroupRuleTypeEngineImpl.java
index 9896549c8d..f311c042c4 100644
--- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/RuleFlowGroupRuleTypeEngineImpl.java
+++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/RuleFlowGroupRuleTypeEngineImpl.java
@@ -73,6 +73,9 @@ public class RuleFlowGroupRuleTypeEngineImpl implements RuleFlowGroupRuleTypeEng
rsni.removeEventListeners();
rsni.retractFacts(kruntime);
rsni.triggerCompleted();
+ if (kruntime instanceof KieSession) {
+ ((KieSession) kruntime).dispose();
+ }
}
}
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
index c6887717ce..4a8cca632c 100755
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
@@ -363,7 +363,6 @@ public class ActivityTest extends JbpmBpmn2TestCase {
List<String> list = new ArrayList<>();
kruntime.getKieSession().setGlobal("list", list);
KogitoProcessInstance processInstance = kruntime.startProcess("RuleTask");
- kruntime.getKieSession().setGlobal("list", list);
assertThat(list).hasSize(1);
assertProcessInstanceFinished(processInstance, kruntime);
}
@@ -452,14 +451,16 @@ public class ActivityTest extends JbpmBpmn2TestCase {
params = new HashMap<>();
- processInstance = kruntime.startProcess("RuleTask", params);
+ KogitoProcessRuntime kruntime2 = createKogitoProcessRuntime("BPMN2-RuleTaskWithFact.bpmn2", "BPMN2-RuleTask3.drl");
+ processInstance = kruntime2.startProcess("RuleTask", params);
assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ERROR);
+ KogitoProcessRuntime kruntime3 = createKogitoProcessRuntime("BPMN2-RuleTaskWithFact.bpmn2", "BPMN2-RuleTask3.drl");
params = new HashMap<>();
params.put("x", "SomeString");
- processInstance = kruntime.startProcess("RuleTask", params);
- assertProcessInstanceFinished(processInstance, kruntime);
+ processInstance = kruntime3.startProcess("RuleTask", params);
+ assertProcessInstanceFinished(processInstance, kruntime3);
}
@Test
@@ -475,7 +476,6 @@ public class ActivityTest extends JbpmBpmn2TestCase {
KogitoProcessInstance processInstance2 = kruntime2.startProcess("RuleTask");
assertProcessInstanceFinished(processInstance1, kruntime);
assertProcessInstanceFinished(processInstance2, kruntime2);
- kruntime2.getKieSession().dispose(); // kruntime's session is disposed in the @AfterEach method
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org