-
-
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
Use @JsonProperty
for Enum values also when READ_ENUMS_USING_TO_STRING
enabled
#4036
Use @JsonProperty
for Enum values also when READ_ENUMS_USING_TO_STRING
enabled
#4036
Conversation
Hmmm. I guess this is a reasonable request as Can not fully validate suggested fix (although it makes sense); @JooHyukKim knows better I think having rewritten most of this code very recently. |
When |
Can we use "improve" instead of "fix" in the title, @iProdigy ? Because some (bug) fixes can be merged back to 2.15, it's better not to look back and look for what bug we are trying to fix here. WDYT, @cowtowncoder ?
I will take a look, seems straightforward though. |
if (name == null) { | ||
name = enumValue.toString(); | ||
} | ||
map.put(name, enumValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioend in the comment, we may not need to change behavior in this deprecated method
src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserializationTest.java
Show resolved
Hide resolved
It's a straightforward, so I think it work just fine. @cowtowncoder. How about backporting to 2.15? |
I think that for safety wrt avoiding regression, we should not try backporting improvements to behavior here. @iProdigy yes I agree that name from @JooHyukKim behavior of deprecated methods is something we could do either way, no strong opinion (that is; can fix, can leave without fix, as long as methods no longer called from within databind itself). |
Agreed, shall I update this PR with the serialization side or create a separate PR? |
@iProdigy Ah! Sorry, missed the ser/deser part. Yeah, I think separate PR might make sense -- but either way is fine with me. |
Ok one last thing @iProdigy -- if you havent been asked for (and sent) CLA, from: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf we'd need that before merging the first contribution (once we have it, it's good for any number of contributions). |
@cowtowncoder Just sent the signed CLA to that inbox! |
LGTM! |
If that's the case, may I suggest "not" to make modifications in deprecated methods? For following reasons...
WDYT? /cc @cowtowncoder @iProdigy |
It's worth noting that the deprecated
That said, these scenarios shouldn't (?) occur on 2.16, so updating the deprecated method may not be necessary |
CLA received; will look over once more, then merge. As to deprecated methods; yeah, need to be careful but at least existing unit test suite can catch some obvious issues. |
@JsonProperty
for Enum values also when READ_ENUMS_USING_TO_STRING
enabled
@JooHyukKim Good points in favor of NOT adding support, I concur. |
@iProdigy Deleted earlier comment, because I thought we finished something before actually checking 😆. Anyways, thank you also! |
When
DeserializationFeature.READ_ENUMS_USING_TO_STRING
is enabled, the enum deserializer neglects inspecting@JsonProperty
; see the test case, it succeeds ifREAD_ENUMS_USING_TO_STRING
is disabled and would fail withREAD_ENUMS_USING_TO_STRING
enabled (without this patch).