Marcin-Pankowski commented on code in PR #7313:
URL: https://github.com/apache/incubator-kie/pull/7313#discussion_r4677577544


##########
kogito-quarkus/addons/persistence/kafka/runtime/src/main/java/org/kie/kogito/persistence/kafka/KafkaProcessInstances.java:
##########
@@ -218,13 +217,13 @@ protected void connectInstance(ProcessInstance<?> 
instance) {
     @Override
     public Stream<ProcessInstance<T>> waitingForEventType(String eventType, 
ProcessInstanceReadMode mode) {
 
-        KeyValueIterator<String, byte[]> iterator = 
getStore().prefixScan("events-" + getProcess().id(), 
Serdes.String().serializer());
-        if (!iterator.hasNext()) {
-            return Collections.<ProcessInstance<T>> emptyList().stream();
+        byte[] eventData;
+        try (KeyValueIterator<String, byte[]> iterator = 
getStore().prefixScan("events-" + getProcess().id(), 
Serdes.String().serializer())) {

Review Comment:
   Good point, thanks! Both `waitingForEventType` and `clearEventTypes` now use 
`getStore().get(getKeyForEvents())`. Besides dropping the iterator, it also 
avoids a subtle issue: `prefixScan("events-" + processId)` also matches the 
events record of another process whose id starts with the same string (e.g. 
`events-Order` and `events-OrderFoo`), so with a shared topic it could return 
the other process's list when the own record does not exist yet.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to