Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegating JsonCreator disregards JsonDeserialize.as (and contentAs) annotation #2016

Closed
carterkozak opened this issue Apr 30, 2018 · 4 comments
Milestone

Comments

@carterkozak
Copy link
Contributor

Given a class of this form, the documentation suggests that value should be created as a LinkedList, however it is always an ArrayList. Furthermore, if I modify the @JsonDeserialize annotation with incorrect values (e.g. as = HashMap.class) it does not change behavior.

public final class Wrapper {
    private final List<String> value;

    @JsonCreator
    public Wrapper(@JsonDeserialize(as = LinkedList.class) List<String> value) {
        this.value = value;
    }

    @JsonValue
    public List<String> getValue() {
        return value;
    }
}

If I expect an object with a property by using a @JsonProperty annotation, the @JsonDeserialize annotation does work as expected.

Simple repro here:
https://github.com/cakofony/jackson-jsoncreator-deserializeas-repro

Test class is located here

Happy to provide additional info.
Thanks!

@cowtowncoder
Copy link
Member

Yes, seems legit; @JsonDeserialize should be taken into account. And since there is explicit @JsonCreator this should not be due to failed merging of annotation.

@cowtowncoder
Copy link
Member

Ok, I can reproduce this. Looks like usual type refinement is not called for parameters to delegating-creator; and this would also prevent custom using/contentUsing/keyUsing deserializer assignments as well. So will be adding tests, figuring out how to make it work as expected.
As far as I can see has probably never worked so is not regression.

@cowtowncoder cowtowncoder added this to the 2.9.6 milestone May 4, 2018
cowtowncoder added a commit that referenced this issue May 4, 2018
@cowtowncoder
Copy link
Member

Thank you for reporting this! I will see if I can also test and (if need be) fix support for using annotation as well, for custom deserializers.

Fix will be in 2.9.6.

@cowtowncoder cowtowncoder changed the title Delegating JsonCreator disregards JsonDeserialize info Delegating JsonCreator disregards JsonDeserialize.as (and contentAs) annotation May 4, 2018
@carterkozak
Copy link
Contributor Author

Wonderful, thanks for the fix @cowtowncoder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants