Skip to content

@JsonCreator not used in case of multiple creators with parameter names #421

@lpandzic

Description

@lpandzic

Currently deserialiazing a class that has multiple creators with available parameter names doesn't prioritize the creator annotated with @JsonCreator.

In the new java 8 ParameterNamesAnnotationIntrospector parameter names are resolved for every creator in a class that has been compiled with -parameters option. JacksonAnnotationIntrospector on the other hand, can resolve parameter names only by using @JsonProperty.
When there are multiple creators with parameter names available it seems that the creator with longest parameter list is the preffered one. In the case of JacksonAnnotationIntrospector this is not a problem since it wouldn't make sense for a client to annotate parameters with @JsonProperty on more than one creator.

I've made a test that isolates this issue in a fork. The mocked introspector mimics the behavior of the ParameterNamesAnnotationIntrospector in the new module and if you ignore the givenAnnotationIntrospectorFindsConstructorParameterNames in the test the test will pass.

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