chibenwa commented on code in PR #2991:
URL: https://github.com/apache/james-project/pull/2991#discussion_r3032432249
##########
event-bus/api/src/main/java/org/apache/james/events/EventSerializersAggregator.java:
##########
@@ -37,70 +37,34 @@ public EventSerializersAggregator(Set<EventSerializer>
allEventSerializers) {
}
@Override
- public String toJson(Event event) {
+ public Optional<String> toJson(Event event) {
return allEventSerializers.stream()
- .map(eventSerializer -> serialize(event, eventSerializer))
+ .map(eventSerializer -> eventSerializer.toJson(event))
.flatMap(Optional::stream)
- .findFirst()
- .orElseThrow(() -> new RuntimeException("Could not serialize
event: " + event));
+ .findFirst();
Review Comment:
I think the caller would need to `orElseThrow` this is cleaner.
It represents the fact that you could be in a (bad) position that your
serializer do not handle your event...
--
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]