Skip to content

Abstract Type mapping in 2.9 fails when multiple modules are registered #2019

@asger82

Description

@asger82

If multiple modules are used to map abstract types, deserialization might fail in 2.9+:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of model.Datatype1 (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

The bug can be reproduced for version 2.9+ in the attached maven project.

I guess the bug was introduced due to a modification of _mapAbstractType2 in com.fasterxml.jackson.databind.deser.BasicDeserializerFactory:

2.9:
JavaType concrete = resolver.findTypeMapping(config, type);
if (ClassUtil.rawClass(concrete) != currClass) {
return concrete;
}

2.8
if (concrete != null && concrete.getRawClass() != currClass) {
return concrete;
}

The not null check is needed for continuing iterating other modules for abstract type mappings.

jackson-error-example.zip

Best regards
Asger Christiansen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions