chibenwa commented on code in PR #2465:
URL: https://github.com/apache/james-project/pull/2465#discussion_r1813352660


##########
event-bus/cassandra/src/main/java/org/apache/james/events/CassandraEventDeadLetters.java:
##########
@@ -89,4 +111,26 @@ public Flux<Group> groupsWithFailedEvents() {
     public Mono<Boolean> containEvents() {
         return cassandraEventDeadLettersDAO.containEvents();
     }
+
+    private Event deserialize(String json) {
+        List<Event> events = allEventSerializers.stream()
+            .map(eventSerializer -> Optional.ofNullable(deserialize(json, 
eventSerializer)))
+            .filter(Optional::isPresent)
+            .map(Optional::get)
+            .toList();
+
+        switch (events.size()) {
+            case 0: throw new RuntimeException("Could not deserialize event: " 
+ json);
+            case 1: return events.getFirst();
+            default: throw new RuntimeException("More than one serializers 
could deserialize event: " + json);
+        }

Review Comment:
   Is this a check we need to do at runtime or we could do it at startup?
   
   Because then we could just findFirst...orElseThrow



-- 
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: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to