Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispose KieSession after rules execution when using ruleFlowGroup #3678

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading