-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Converter doesn't work without @JsonCreator for Records #3747
Comments
I wonder if this fails against latest Lombok case may be different: it all depends on how Lombok pre-processes class definitions; although I think POJOs will generally require use of So basically this would be two separate (but related) issues: whether this works for Records (it should), and for POJOs (likely not as there is no definition of "canonical constructor" nor necessarily parameter names). |
I also tried with the de-lomboked version (private final fields, getters, single constructor) and saw the same behavior - had to add |
I changed the title here to refer to just Records: separate one would be needed for POJOs. Or alternatively may change this to refer to POJOs, file new one for Records if issue is still reproducible. Two cases need to be dealt with separately I think. |
With the renamed title, it now becomes duplicate of #3297? |
@yihtserns Which is, I think, fixed? But yes, will close as duplicate. EDIT: Actually, will hold off not closing yet. |
@zman0900 There has been a major update with #3724 -- if you have any way to test your code against 2.15.0-SNAPSHOT (either built locally, or from Sonatype Snapshot repo), it'd be good to see if your use case might now work too. |
Yupe I've tested with But yeah @zman0900 can also verify that it works on his side, before closing this. |
@zman0900 about the issue with Lombok, I think you should create another issue for that discussion as suggested because something weird and very different is going on over there.
|
Hello! I am actually facing this issue when used in conjunction
I receive the following exception:
When I use
To add some context, the API I am using returns |
@lbkulinski I'm not able to reproduce your issue when using I recommend that you create a new issue, together with a sample Github repo that reproduces that issue. |
Will do. Thanks! |
@lbkulinski (From a quick glance, I suspect that error is due to version of |
Yes, that exceptions is due to mismatch: |
Yep. That was it! I had just been using |
Describe the bug
When annotation like
@JsonDeserialize(converter = MyConverter.class)
is applied to a component of a Record or to a field of an immutable class (such as lombok @value or just plain class with final fields, all-args constructor, and only getters), it seems the Converter is not actually used unless@JsonCreator
is also present on the constructor.Version information
Jackson Databind 2.14.1 (with parameter names module)
Java 17
To Reproduce
Given converter class like:
And some JSON like this:
I believe Jackson should be able to bind this Record:
Or bind this class:
But these lead to errors like:
Adding a compact constructor to the Record (or explicit all-args constructor to the class) that is annotated with
@JsonCreator
works around this.I don't believe this should be necessary, as using custom deserializer like
@JsonDeserialize(using = MyDeserializer.class)
seems to work fine without it.The text was updated successfully, but these errors were encountered: