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


##########
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:
   Really difficult to check at startup
   
   Although there is a very small chance this case happen, I still want to 
check this case just for precaution.



-- 
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