-
-
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
Feature #2536 : "READ_ENUM_KEYS_USING_INDEX" to match "WRITE_ENUM_KEYS_USING_INDEX" #3764
Feature #2536 : "READ_ENUM_KEYS_USING_INDEX" to match "WRITE_ENUM_KEYS_USING_INDEX" #3764
Conversation
src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java
Outdated
Show resolved
Hide resolved
@@ -417,6 +431,18 @@ private EnumResolver _getToStringResolver(DeserializationContext ctxt) | |||
} | |||
return res; | |||
} | |||
|
|||
private EnumResolver _getIndexResolver(DeserializationContext ctxt) { | |||
EnumResolver res = _byIndexResolver; |
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.
this form of double-checked locking is not thread-safe, see https://shipilev.net/blog/2014/safe-public-construction/
_byIndexResolver needs to be volatile
src/main/java/com/fasterxml/jackson/databind/util/EnumResolver.java
Outdated
Show resolved
Hide resolved
src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserializationTest.java
Outdated
Show resolved
Hide resolved
Thanks for the guidances guys! New version with all the points implmented/revised up |
src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java
Show resolved
Hide resolved
} | ||
} | ||
} | ||
return _byNameResolver; |
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.
should be _byIndexResolver
src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java
Outdated
Show resolved
Hide resolved
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.
lgtm but will need @cowtowncoder's approval to merge
@cowtowncoder do you have any other opinion on this PR? |
Unfortunately I haven't had time to look into it yet -- there's a big backlog of items. But I hope to have a look soon. Thank you for contributing this! |
Ok, one quick note: I do not want to add a new Instead I would like it added using |
@@ -126,7 +126,27 @@ public static EnumResolver constructUsingToString(DeserializationConfig config, | |||
config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)); | |||
} | |||
|
|||
/** | |||
|
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.
Need to add Javadoc that includes @since 2.15
to indicate when method was added.
Aside from |
Crossed out all above because @cowtowncoder explained about enabling I see, these feature are to be moved out. So do we not need this symmetry with I am curious about your opinion on this.
Just to be clear, are we keeping both, or just |
…ithub.com/JooHyukKim/jackson-databind into FasterXML#2536-READ_ENUM_KEYS_USING_INDEX
Right: this is about transitioning enum-related features (over time) to separate |
Thank you @JooHyukKim for contributing this -- I finally had time to merge it, and it will go in 2.15.0 release. |
Description
WRITE_ENUM_KEYS_USING_INDEX
symmetrically, (test case included)Related Issue : Need a Feature like "READ_ENUM_KEYS_USING_INDEX" #2536
Let me know for anything, cheers