Closed Brozen closed 2 years ago
I upgrade Jackson bom to 2.13.2.1, the exception still throws, message changed but the same result😢
I add an annotation to help ignore parameter parse and submit a PR #235 , will you accept it ?😊
Does adding of mode = Mode.DELEGATING
for @JsonCreator
help? That should ensure right interpretation for handling of the single-argument constructor.
Adding mode = JsonCreator.Mode.DELEGATING
changes behavior to use delegation and test passes.
I don't think there is anything to fix here: single-arg Creator case is often ambiguous due to 2 different possibilities.
Yes, It works, Thanks for that!
Ok. I'll close the PR since it seems like only usable for this specific issue.
version: 2.10.4 JDK: AdoptOpenJDK (HotSpot) 11.0.9 OS: macOS Monterey CPU: 2GHz 4C Interl Core i5
I'm serializing and deserializing enums with
@JsonValu
and@JsonCreator
. The code works in a long term, but after I registerParameterNamesModule
, I got a exception when deserializing(serializing is OK), stack trace likes:Here is my test case:
Maybe the reason is
ParameterNamesAnnotationIntrospector
has parsed parameter name ofMeetingStatus.parse(Number)
, and Jackson thinksMeetingStats
has a_creatorProps
in classFactoryBasedEnumDeserializer
, so_deser
field inFactoryBasedEnumDeserializer
is not setted (line 92 atFactoryBasedEnumDeserializer
).And then, when deserialize enum value, due to
_deser
is null andp.isExpectedStartObjectToken()
return false, the value treated as String, and I got the exception above.To resolve this problem, I must modify parameter type of
MeetingStatus.parse(Number)
method and accept aString
parameter, just like this:But too difficut to accept this solution: there is over 100 enums in project, I cannot modify every @JsonCreator method body……
Do you have any solutions? Or I have to remove registration of
ParameterNamesModule
, but it's very helpful😢