Skip to content

Afterburner does not support the new CoercionConfig #120

@carterkozak

Description

@carterkozak

I 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:

private void _verifyScalarCoercion(DeserializationContext ctxt, JsonParser parser, String type) throws IOException {
MapperFeature feat = MapperFeature.ALLOW_COERCION_OF_SCALARS;
if (!ctxt.isEnabled(feat)) {
ctxt.reportInputMismatch(getType(),
"Cannot coerce JSON %s value (%s) into %s (enable `%s.%s` to allow)",
parser.currentToken().name(),
parser.readValueAsTree(),
type,
feat.getClass().getSimpleName(),
feat.name());
}
}

Blackbird appears to be impacted as well (at a glance reading the code, I have not validated with a test yet):

private void _verifyScalarCoercion(DeserializationContext ctxt, JsonParser parser, String type) throws IOException {
MapperFeature feat = MapperFeature.ALLOW_COERCION_OF_SCALARS;
if (!ctxt.isEnabled(feat)) {
ctxt.reportInputMismatch(getType(),
"Cannot coerce JSON %s value (%s) into %s (enable `%s.%s` to allow)",
parser.currentToken().name(),
parser.readValueAsTree(),
type,
feat.getClass().getSimpleName(),
feat.name());
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions