Event getting persisted as a byte when I forgot to register to the JSON serializer


(Joo) #1

Hi all,

I found that when the develop forgets to register any event type to the JSON serializer registry, instead of Lagom throwing an exception when the event is getting persisted into the journal, it persist the event as a byte[] and throw an exception when you try to recover from the events.

Here is the example of the error message:

2019-02-17T11:11:48.812Z [e[31merrore[0m] vxcv[] - Exception in RestCallIdImpl(GET,/api/internal/vxvc/i
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('¬' (code 172)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: (byte[])"�� sr ^com....impl.entities.goal.ces.events.package$PlanCompositionUpdatedEvtx���m L compositiont VLcom/endowus/silver/composition/impl/commons/composition/package$PortfolioComposition;L planIdt Ljava/util/UUID;xpsr Tcom.endowus.silver.composition.impl.commons.composition.package$PortfolioComposition�'��W��!  L actualPortfoliot QLcom/endowus/silver/composition/impl/commons/composition/package$ActualPortfolio;L bondHoldingsCountt Lscala/Option;L bondSectorAll"[truncated 12023 bytes]; line: 1, column: 2]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1798)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:561)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2625)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:826)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:723)

Shouldn’t it be more correct to NOT persist the event at all if there is no known JSON Serializer registered for the particular event, instead of persisting it as a byte?


(Patrik Nordwall) #2

I agree that this seems wrong, please open an issue in Lagom Github.