chibenwa commented on code in PR #2465: URL: https://github.com/apache/james-project/pull/2465#discussion_r1813352954
########## 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); + } + } + + private Event deserialize(String json, EventSerializer eventSerializer) { + try { + return eventSerializer.asEvent(json); + } catch (Exception ex) { + return null; Review Comment: return null spotted!!! -- 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