Afterburner does not support the new CoercionConfig
See original GitHub issueI have a project which disables scalar coercion, however allows serialization and deserialization of java long
, java.lang.Long
, and java.util.OptionalLong
values as strings to avoid javascript number truncation. Upgrading to 2.12.0 I replaced custom deserializers with CoercionConfig, however optimized accessors fail with:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot coerce JSON VALUE_STRING value ("1") into long (enable `MapperFeature.ALLOW_COERCION_OF_SCALARS` to allow)
at [Source: (String)"{"value":"1"}"; line: 1, column: 10]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1603)
at com.fasterxml.jackson.module.afterburner.deser.OptimizedSettableBeanProperty._verifyScalarCoercion(OptimizedSettableBeanProperty.java:405)
at com.fasterxml.jackson.module.afterburner.deser.OptimizedSettableBeanProperty._deserializeLong(OptimizedSettableBeanProperty.java:305)
at com.fasterxml.jackson.module.afterburner.deser.SettableLongMethodProperty.deserializeAndSet(SettableLongMethodProperty.java:40)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:159)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4591)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3546)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3514)
The afterburner module should respect the CoercionConfig, currently it only checks MapperFeature.ALLOW_COERCION_OF_SCALARS
:
https://github.com/FasterXML/jackson-modules-base/blob/6876b282d56983cc0296dc1ce5346503d8bc11e6/afterburner/src/main/java/com/fasterxml/jackson/module/afterburner/deser/OptimizedSettableBeanProperty.java#L402-L413
Blackbird appears to be impacted as well (at a glance reading the code, I have not validated with a test yet): https://github.com/FasterXML/jackson-modules-base/blob/6876b282d56983cc0296dc1ce5346503d8bc11e6/blackbird/src/main/java/com/fasterxml/jackson/module/blackbird/deser/OptimizedSettableBeanProperty.java#L381-L392
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Starting work on this, bigger than I thought but important to get parity.
Ok I think this should work now. Did a sizable detour by first copying quite a bit of handling code from
StdDeserializer
, before realizing that I can delegate non-default input shapes and keep code not only much tighter but also more compliant (since delegating uses default databind handling in that case).@carterkozak Would appreciate if you could see if snapshot from 2.12 works better at this point.