Arsnael commented on code in PR #2991:
URL: https://github.com/apache/james-project/pull/2991#discussion_r3037701941


##########
mailbox/event/json/src/main/scala/org/apache/james/event/json/MailboxEventSerializer.scala:
##########
@@ -456,17 +456,31 @@ class JsonSerialize(mailboxIdFactory: MailboxId.Factory, 
messageIdFactory: Messa
 class MailboxEventSerializer @Inject()(mailboxIdFactory: MailboxId.Factory, 
messageIdFactory: MessageId.Factory, quotaRootDeserializer: 
QuotaRootDeserializer) extends EventSerializer {
   private val jsonSerialize = new JsonSerialize(mailboxIdFactory, 
messageIdFactory, quotaRootDeserializer)
 
-  override def toJson(event: JavaEvent): String = jsonSerialize.toJson(event)
+  override def toJson(event: JavaEvent): Optional[String] = 
Optional.of(jsonSerialize.toJson(event))
 
-  override def toJsonBytes(event: JavaEvent): Array[Byte] = 
jsonSerialize.toJsonBytes(event)
+  override def toJsonBytes(event: JavaEvent): Optional[Array[Byte]] = 
Optional.of(jsonSerialize.toJsonBytes(event))
 
-  override def toJsonBytes(event: util.Collection[JavaEvent]): Array[Byte] = 
jsonSerialize.toJsonBytes(event)
+  override def toJsonBytes(event: util.Collection[JavaEvent]): 
Optional[Array[Byte]] = Optional.of(jsonSerialize.toJsonBytes(event))
 
   def fromJson(json: String): JsResult[JavaEvent] = 
jsonSerialize.fromJson(json)
 
-  override def toJson(event: util.Collection[JavaEvent]): String = 
jsonSerialize.toJson(event)
+  override def toJson(event: util.Collection[JavaEvent]): Optional[String] = 
Optional.of(jsonSerialize.toJson(event))
 
-  override def asEvents(serialized: String): util.List[JavaEvent] = 
jsonSerialize.fromJsonAsEvents(serialized).get.asJava
+  override def asEvents(serialized: String): Optional[util.List[JavaEvent]] = {
+    val result = jsonSerialize.fromJsonAsEvents(serialized)
+    if (result.isError) {
+      Optional.empty()

Review Comment:
   Will give it a shot thanks for the suggestion



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

Reply via email to