-
Notifications
You must be signed in to change notification settings - Fork 175
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
"Input mismatch reading Enum" after upgrade to Jackson 2.11 #336
Comments
I've encountered this problem with Java too, when using |
So, should this issue still be reported against https://github.com/FasterXML/jackson-databind instead (despite the move of @cowtowncoder)? When looking at the issues over there I wondered whether FasterXML/jackson-databind#2725 is related to this issue. |
@sschuberth If test can be simplified to only use Java (and ideally just include test class in comment), |
See https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.11.1. This fixes #2796 by applying the work-around described at [1] as our Jackson version was actually already being upgraded to version 2.11.0 by Gradle via the Antenna dependency. [1] FasterXML/jackson-module-kotlin#336 (comment) Signed-off-by: Sebastian Schuberth <[email protected]>
See https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.11.1. This fixes #2796 by applying the work-around described at [1] as our Jackson version was actually already being upgraded to version 2.11.0 by Gradle via the Antenna dependency. [1] FasterXML/jackson-module-kotlin#336 (comment) Signed-off-by: Sebastian Schuberth <[email protected]>
See https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.11.1. This fixes #2796 by applying the work-around described at [1] to enums as our Jackson version was actually already being upgraded to version 2.11.0 by Gradle via the Antenna dependency. [1] FasterXML/jackson-module-kotlin#336 (comment) Signed-off-by: Sebastian Schuberth <[email protected]>
See https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.11.1. This fixes #2796 by applying the work-around described at [1] to enums as our Jackson version was actually already being upgraded to version 2.11.0 by Gradle via the Antenna dependency. [1] FasterXML/jackson-module-kotlin#336 (comment) Signed-off-by: Sebastian Schuberth <[email protected]>
How's that:
This works as is with Jackson 2.10.x but fails with aforementioned error on Jackson 2.11 unless
Which Jackson version behaves properly? |
@bentmann thank you! I'll transfer this, have a look. |
Oh, actually, no. @bentmann Problem here is that example is fundamentally ambiguous at outer level. It could legally be either delegating or properties-based -- of which only delegating can work due to inner definition that is detectable as Properties one (due to addition of In this case, you really should indicate mode for both. This can not be changed to reliably work as-is. |
OK, thanks for the clarification |
Is this issue fixed? Or is there another issue to fix it? Because I also have this problem. If I fix one case, the other one breaks, and vice versa. |
@bushwakko There is nothing that can be fixed here as far as I can see -- single-argument creator must indicate correct binding type: either "properties-based' or "delegating". @lpandzic's answer is correct; @bentmann's example is broken since it defines property-name for argument but expects delegating-style content. I am not sure what you mean by two cases, but if you mean that you would have to accept both JSON Object and JSON String as values, you will need to implement custom Creator, taking either |
@cowtowncoder is there a way to workaround the openapi-generator issue which just uses |
Today this can be solved with a custom module with a custom annotation introspector similar to SingleArgumentPropertiesCreatorModeAnnotationIntrospector. The one I linked does the necessary steps to determine if the single argument constructor is actually a property based one and tells jackson to mark it as such (SingleArgumentPropertiesCreatorModeAnnotationIntrospectorTest). Similar approach could be used for opposite case - DELEGATING creator one. The crux of the issue, from my view, is that each object is created through either delegating or property based mode and single argument constructor is a edge case because of historical reasons (pre Java 8 it was very unconventional not to have a (mutable) pojo in your model). |
Aside from https://cowtowncoder.medium.com/jackson-2-12-most-wanted-3-5-246624e2d3d0 For example:
|
Thanks a lot for the recommendations. I realized that we configured the visibility of fields to be any in the |
Hi, is there any workaround for this? as soon as we have the enum generated i cannot use |
After upgrading Jackson from 2.10.3 to 2.11.0 we started to see "Input mismatch reading Enum" errors when deserializing this Koltin Enum class which has a custom
@JsonCreator
.To reproduce, you may want to check out this PR and run the added test via
with and without the
Revert "Gradle: Upgrade Jackson to version 2.11.0"
commit.The full error is:
The text was updated successfully, but these errors were encountered: