FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

[Avro] BC-break in 2.11.3 #224

Closed marcospassos closed 3 years ago

marcospassos commented 3 years ago

We updated our codebase to 2.11.3 and started getting the following error everywhere:

com.fasterxml.jackson.databind.JsonMappingException: class java.util.LinkedHashMap cannot be cast to class com.croct.platform.domain.user.UserAddress (java.util.LinkedHashMap is in module java.base of loader ‘bootstrap’; com.croct.platform.domain.user.UserAddress is in unnamed module of loader ‘app’)
 com.croct.platform.domain.serialization.user.UserProfileMixin$Builder[“address”])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:281)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:623)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:611)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeSetAndReturn(MethodProperty.java:173)
    at com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.vanillaDeserialize(BuilderBasedDeserializer.java:274)
    at com.fasterxml.jackson.databind.deser.BuilderBasedDeserializer.deserialize(BuilderBasedDeserializer.java:198)
    at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2079)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1518)

For some reason, some classes cannot get deserialized (we're using mixins with builders).

Any idea what was introduced in 2.11.3 that can be causing these errors?

cowtowncoder commented 3 years ago

Sigh. No idea what specifically would be, although guessing that from databind fixes, either issue 2821 or 2846 might be relevant. Low level exception itself suggests loss of type information somewhere, type resolution failing.

I doubt this is Avro-specific, wondering if this:

https://github.com/FasterXML/jackson-databind/issues/2876

might be due to same root cause, whatever it is.

cowtowncoder commented 3 years ago

Actually, more like this one:

https://github.com/FasterXML/jackson-databind/issues/2876

which is fixed and will be included in 2.11.4 (not yet out).

marcospassos commented 3 years ago

Just for clarity, is this a hypothesis, or have you checked if this issue goes away with this fix?

cowtowncoder commented 3 years ago

@marcospassos Without reproduction of the problem it is just a hypothesis, but symptoms and fix in question seem quite plausible. So if you have an easy way to verify it would be good to find out either way -- I hope to release 2.11.4 soon, before going on for my christmas break.

cowtowncoder commented 3 years ago

Fwtw, 2.11.4 was released 12-Dec-2020. Then again 2.12 is out, latest being 2.12.3 as well.

At this point, a unit test would be required to reproduce the problem if it still remains.

marcospassos commented 3 years ago

Fixed in https://github.com/FasterXML/jackson-databind/issues/3220