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 2026/02/06 14:01:47 UTC

(incubator-kie-kogito-runtimes) branch main updated: [incubator-kie-issues-2240] Fix MongoDB events filter handling (#4186)

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 44f8c2e976 [incubator-kie-issues-2240] Fix MongoDB events filter handling (#4186)
44f8c2e976 is described below

commit 44f8c2e976cadb900b496815100f1197b075ac14
Author: Martin Cimbalek <mc...@redhat.com>
AuthorDate: Fri Feb 6 15:01:42 2026 +0100

    [incubator-kie-issues-2240] Fix MongoDB events filter handling (#4186)
---
 .../org/kie/kogito/mongodb/MongoDBProcessInstances.java   | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/MongoDBProcessInstances.java b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/MongoDBProcessInstances.java
index 8e82ce0ccd..d314417971 100644
--- a/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/MongoDBProcessInstances.java
+++ b/addons/common/persistence/mongodb/src/main/java/org/kie/kogito/mongodb/MongoDBProcessInstances.java
@@ -104,11 +104,13 @@ public class MongoDBProcessInstances<T extends Model> implements MutableProcessI
     @Override
     public Stream<ProcessInstance<T>> waitingForEventType(String eventType, ProcessInstanceReadMode mode) {
         ClientSession clientSession = transactionManager.getClientSession();
-        Bson eventTypeFilter = Filters.all("eventTypes", eventType);
+        Bson eventTypeFilter = new Document("eventTypes", eventType);
         List<String> processInstancesId = new ArrayList<>();
-
-        events.find(eventTypeFilter).forEach(e -> processInstancesId.add(e.getString("id")));
-
+        if (clientSession != null) {
+            events.find(clientSession, eventTypeFilter).forEach(e -> processInstancesId.add(e.getString("id")));
+        } else {
+            events.find(eventTypeFilter).forEach(e -> processInstancesId.add(e.getString("id")));
+        }
         Bson filters = Filters.in("id", processInstancesId);
         MongoCursor<Document> docs = (clientSession == null ? collection.find(filters) : collection.find(clientSession, filters)).iterator();
         return StreamSupport.stream(Spliterators.spliteratorUnknownSize(docs, Spliterator.ORDERED), false).map(doc -> unmarshall(doc, mode)).onClose(docs::close);
@@ -176,6 +178,7 @@ public class MongoDBProcessInstances<T extends Model> implements MutableProcessI
 
     private void updateInternal(String id, ProcessInstance<T> instance, ClientSession clientSession, Document doc, Set<String> eventTypes) {
         Bson filters = Filters.eq(PROCESS_INSTANCE_ID, id);
+        Bson eventsFilter = Filters.eq(PROCESS_INSTANCE_ID, id);
         UpdateResult result;
         if (lock) {
             doc.put(VERSION, instance.version() + 1);
@@ -187,10 +190,10 @@ public class MongoDBProcessInstances<T extends Model> implements MutableProcessI
 
         if (clientSession != null) {
             result = collection.replaceOne(clientSession, filters, doc);
-            events.replaceOne(clientSession, filters, eventsDocument);
+            events.replaceOne(clientSession, eventsFilter, eventsDocument);
         } else {
             result = collection.replaceOne(filters, doc);
-            events.replaceOne(filters, eventsDocument);
+            events.replaceOne(eventsFilter, eventsDocument);
         }
 
         if (lock && result.getModifiedCount() != 1) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org