-
-
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
EnumSet
deserialization does not work when we activate default typing in ObjectMapper
#4214
Comments
I proposed a fix with PR - #4215 |
Ok, now we have a reproduction at least. Looks like |
Ok, actually, it's not so much I don't know if I have time to work much more on this issue but if anyone wants to try to figure it out would be happy to review PR. |
Ok, one more note: it looks like |
EnumSet
deserialization does not work when we activate default typing in ObjectMapper
Was able to fix; deprecated older methods, fix will be in 2.17.0. |
…s something wrt original problem
Search before asking
Describe the bug
If we serialize an object which has a property of type Set, but referring EnumSet at runtime, then serialization uses CollectionSerializer instead of EnumSetSerializer for this property, when we activate default typing in ObjectMapper. This causes deserialization (using EnumSetDeserializer) to fail, since EnumSetDeserializer expects encoding of EnumSetSerializer, but not of CollectionSerializer.
Version Information
2.14.0 and above
Reproduction
If we run the below given test (java code), we get following error:
[ERROR] EnumSetSerializationTest.testSerialization:69 » MismatchedInput Cannot deserialize value of type
com.fasterxml.jackson.databind.ser.enums.EnumSetSerializationTest$MyEnum
from Array value (tokenJsonToken.START_ARRAY
)at [Source: REDACTED (
StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION
disabled); line: 1, column: 191] (through reference chain: com.fasterxml.jackson.databind.ser.enums.EnumSetSerializationTest$EnumSetHolder["enumSet"]->java.util.RegularEnumSet[0])Expected behavior
Above given test code should pass.
Additional context
As a workaround, if we make type of EnumSetHolder#enumSet property as EnumSet instead of Set, in the above given code, test passes.
No response
The text was updated successfully, but these errors were encountered: