-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support deserialization in GenericJackson2JsonRedisSerializer
when using custom JsonFactory
#2981
Comments
We're using a pristine I suggest that you explore options that let our test suite pass while you're able to address your issue. |
GenericJackson2JsonRedisSerializer
when using custom JsonFactory
Thanks for the explanation. So it looks like using ObjectMapper which has enabled typing (like this) will not work for type resolver, right? Since our mapper does not enable it, it will still work. I am thinking we can expose a public function to support setting the custom mapper in type resolver (and add a comment that mappers which has enabled typing will not work). I have a draft PR. I don't think it is a clean approach, but have not come up with a better alternative. Could you help take a look? |
Thanks for looking into it. We indeed are looking for an approach that doesn't require additional configuration. I created an approach by using |
Awesome. I have closed my draft PR and will wait for yours. Thanks! |
We create RedisCacheConfiguration with value serializer like this:
It uses an ObjectMapper with a custom JsonFactory (MessagePackFactory). Serialization works correctly, but deserialization encounters the following exception:
The error happens on this line at resolveType. The cause is that TypeResolver uses a default ObjectMapper which would throw exception here during deserialization when the value is serialized by our ObjectMapper with custom JsonFactory as shown above. The default ObjectMapper uses MappingJsonFactory in comparison.
Solution: when creating the TypeResolver here, we should use the ObjectMapper which was passed in here, and store it on the TypeResolver to use. Or at least make that an option so we can use it to avoid the deserialization error. I have tested that it can fix the deserialization issue, but not sure if there is any other implication.
FYI, our code was working fine with spring-data-redis 2.7.x but encountered this issue now as we are upgrading to spring-data-redis 3. It's because of this commit which changed the deserialization function and added resolveType.
The text was updated successfully, but these errors were encountered: