-
-
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
Deserialization of enums with name defined with different cases leads to InvalidDefinitionException
: Multiple fields representing property
#4409
Comments
Thank you for reporting this, @sbailliez ! It definitely looks like a bug. Two immediate guesses for possible triggering part (will try to see if they are related).
|
InvalidDefinitionException
: Multiple fields representing property
Yes, looks like Possibly related:
|
Quick note: I haven't dig into why
|
Ok the problem is that names do translate both to So this is a problem that was not detected until 2.15 (I think) -- behavior in 2.16 is as expected going forward. In case where naming strategy converts value into conflicts, annotation is needed, or possible
does not seem to help in this case (assuming it will not translate relevant values into separate ones) |
Closing as wont-fix; solution is to apply annotation on one of conflicting values. |
/cc @JooHyukKim you might be interested in this -- I had forgotten that the per-mapper default |
Right, from users could feel awkward who are used to having Enums unaffected by WRT, keeping backward compatibility either...
// name yet TBD
EnumFeature.APPLY_PROPERTY_NAMING_STRATEGY_TO_ENUMS ...such to keep the |
This is probably the first time that I see that the naming strategy was "supposed" to be applied to enums values. I thought there were expected to be serialized/deserialized as is and you would use valueOf or fromString to impact it. So I would vote for keeping backward compatibility. In my case this is a thirdparty library, so I cannot add annotations but will open a bug for trying to annotate it explicitly to make it compatible for all jackson versions. |
I must say I did not remember that I think This could mean that strategy should, by default, apply, but may be disabled by the new |
Okay, so will modify PR #4414 to implement the new But WRT version, shouldn't we have the feature provided in 2.16? So users upgrading from 2.15 can easily fix things, like case here. |
No, as per SemVer no features may be added in patch releases: all patch releases should have same API -- additions may be done in minor releases. But let's think this through first, before providing more solutions before understanding the problem. What I'd want to know is the actual scope of problem; both wrt version in which behavior changes (wrt |
@sbailliez I may have spoken too soon on this change being intentional wrt |
@JooHyukKim do you mean for 2.15 "NOT applied to both Serialization and Deserialization"? |
@cowtowncoder I believe the reason there has not been any report related to this behavior in 2.16 is that it is pretty unconventional to have enums with values that have a case difference. In the API I refer to it is probably there for backward compatibility. |
@sbailliez True, that makes it less common. Enums often have underscores and some naming conventions change those so... but either way, it is interesting how few problems have been reported |
@JooHyukKim Given this, I feel comfortable disabling application of |
Ok so it's |
Ok. The trick is to check what But in short term (2.17) duplication would be fine.
I might have time to look into this tomorrow, but if not I hope above helps. |
Thanks @sbailliez for reproduction and all! |
Fixed for 2.16.2 |
Search before asking
Describe the bug
I'm using a thirdparty client that is deserializing json where an enum is made of variations like RGBA and RGBa. When upgrading our dependencies from Jackson 2.14.1 to 2.16.1 this API started failing with
Version Information
2.16.1
Looks like the bug was introduced in 2.16.0 as it works with 2.15.4
Reproduction
Expected behavior
This should succeed.
Additional context
For this particular, I worked around this issue right now by patching the objectmapper created within the client and adding a custom deserializer for that enum:
The text was updated successfully, but these errors were encountered: