From 94277b009700e85c985ca5701d3f327de2d4e02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Del=C3=A8gue?= Date: Thu, 18 Jul 2024 15:19:52 +0200 Subject: [PATCH] bug handling batch commands --- .../java/fr/maif/eventsourcing/EventProcessorImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/thoth-core/src/main/java/fr/maif/eventsourcing/EventProcessorImpl.java b/thoth-core/src/main/java/fr/maif/eventsourcing/EventProcessorImpl.java index 5dc13b27..01ac3aa7 100644 --- a/thoth-core/src/main/java/fr/maif/eventsourcing/EventProcessorImpl.java +++ b/thoth-core/src/main/java/fr/maif/eventsourcing/EventProcessorImpl.java @@ -136,9 +136,8 @@ public CompletionStage env._1) .mapValues(l -> l.map(t -> t._2)); // for each original command, we prepare the result that we be returned - return indexedByCommandId.map(t -> { - CommandAndInfos commandAndInfos = t._1; - List> eventEnvelopes = t._2; + return successes.map(commandAndInfos -> { + List> eventEnvelopes = indexedByCommandId.get(commandAndInfos).toList().flatMap(identity()); var mayBeLastSeqNum = eventEnvelopes.map(e -> e.sequenceNum).max(); return new CommandStateAndEvent(commandAndInfos.command, commandAndInfos.mayBeState, eventEnvelopes, commandAndInfos.events.events.toList(), commandAndInfos.events.message, mayBeLastSeqNum); }).toList(); @@ -173,7 +172,7 @@ public CompletionStage - new ProcessingSuccess<>(s.state, mayBeNextState, s.getEventEnvelopes(), s.getMessage()) + new ProcessingSuccess<>(s.getState(), mayBeNextState, s.getEventEnvelopes(), s.getMessage()) ); }) )