Skip to content

Commit

Permalink
Dispose KieSession after rules execution when using ruleFlowGroup (#3678
Browse files Browse the repository at this point in the history
)

* Dispose KieSession after rules execution when using ruleFlowGroup
  • Loading branch information
martinweiler authored Sep 24, 2024
1 parent 0fbddf3 commit 5810447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void evaluate(RuleSetNodeInstance rsni, String ruleFlowGroup) {
rsni.removeEventListeners();
rsni.retractFacts(kruntime);
rsni.triggerCompleted();
if (kruntime instanceof KieSession) {
((KieSession) kruntime).dispose();
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ public void testRuleTask() throws Exception {
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);
}
Expand Down Expand Up @@ -452,14 +451,16 @@ public void afterMatchFired(AfterMatchFiredEvent event) {

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
Expand All @@ -475,7 +476,6 @@ public void testRuleTaskAcrossSessions() throws Exception {
KogitoProcessInstance processInstance2 = kruntime2.startProcess("RuleTask");
assertProcessInstanceFinished(processInstance1, kruntime);
assertProcessInstanceFinished(processInstance2, kruntime2);
kruntime2.getKieSession().dispose(); // kruntime's session is disposed in the @AfterEach method
}

@Test
Expand Down

0 comments on commit 5810447

Please sign in to comment.