You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for final/Kotlin classes in GenericJackson2JsonRedisSerializer [DATAREDIS-995] #1566
As described in detail in this Jackson issue, it is currently not possible to use GenericJackson2JsonRedisSerializer with final classes. That's especially blocking in Kotlin where classes are final by default, and data classes always final.
I have just upgraded Jackson to 2.10.0 in Framework, in time for our 5.2 GA, and Boot will pick up as well. Is it possible to use DefaultTyping.EVERYTHING in order to solve this blocking issue that impacts Kotlin developers?
GenericJackson2JsonRedisSerializer can be created with a given ObjectMapper so you should be able to construct the serializer yourself. We could switch the default. Since the change should be minimal, feel free to submit a pull request and make sure all tests are green.
@mp911de - Started working on a simple PR for that to swap over the DefaultTyping to EVERYTHING enum and added a test for it. Looks like it breaks the null serialization though with shouldSerializeNullValueSoThatItCanBeDeserializedWithDefaultTypingEnabled() throwing a:
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Type id handling not implemented for type org.springframework.cache.support.NullValue
I can still go ahead and submit the PR if you want but I'm a bit at a loss for that one.
For the failing test in GenericJackson2JsonRedisSerializerUnitTests we need to add an override for serializeWithType to the NullValueSerializer that delegates to serialize.
Still, there are more problems related to moving to EVERYTHING.
The DefaultTypeResolverBuilder always returns true when requesting useType even when the given one is a TreeNode.
This breaks the integration test for the Jackson2HashMapper. It seems we need to provide our own flavour of DefaultTypeResolverBuilder that does something like
case EVERYTHING:
return !TreeNode.class.isAssignableFrom(t.getRawClass());
and hook it into the ObjectMapper by overriding _constructDefaultTypeResolverBuilder.
changed the title [-]Add support for final/Kotlin classes in GenericJackson2JsonRedisSerializer [DATAREDIS-995][/-][+]Add support for final/Kotlin classes in `GenericJackson2JsonRedisSerializer` [DATAREDIS-995][/+]on Jan 13, 2022
Activity
spring-projects-issues commentedon Sep 9, 2019
Sébastien Deleuze commented
DefaultTyping.EVERYTHINGhas been added to the upcoming Jackson 2.10 to solve that issue. My proposal is to update Spring Data Redis to use it instead ofDefaultTyping.NON_FINALwhen Jackson 2.10 is in the classpath, otherwise fallback onDefaultTyping.NON_FINAL.FYI Jackson 2.10 should be here on time for Boot 2.2 GA.
spring-projects-issues commentedon Sep 27, 2019
Sébastien Deleuze commented
I have just upgraded Jackson to 2.10.0 in Framework, in time for our 5.2 GA, and Boot will pick up as well. Is it possible to use
DefaultTyping.EVERYTHINGin order to solve this blocking issue that impacts Kotlin developers?azizabah commentedon Jan 10, 2022
@mp911de / @sdeleuze - Is this still open? If so, is there a recommended work-around for Kotlin?
mp911de commentedon Jan 10, 2022
GenericJackson2JsonRedisSerializercan be created with a givenObjectMapperso you should be able to construct the serializer yourself. We could switch the default. Since the change should be minimal, feel free to submit a pull request and make sure all tests are green.azizabah commentedon Jan 10, 2022
@mp911de - Started working on a simple PR for that to swap over the DefaultTyping to EVERYTHING enum and added a test for it. Looks like it breaks the null serialization though with shouldSerializeNullValueSoThatItCanBeDeserializedWithDefaultTypingEnabled() throwing a:
I can still go ahead and submit the PR if you want but I'm a bit at a loss for that one.
christophstrobl commentedon Jan 13, 2022
For the failing test in
GenericJackson2JsonRedisSerializerUnitTestswe need to add an override forserializeWithTypeto theNullValueSerializerthat delegates toserialize.Still, there are more problems related to moving to
EVERYTHING.The
DefaultTypeResolverBuilderalways returnstruewhen requestinguseTypeeven when the given one is aTreeNode.This breaks the integration test for the
Jackson2HashMapper. It seems we need to provide our own flavour ofDefaultTypeResolverBuilderthat does something likeand hook it into the
ObjectMapperby overriding_constructDefaultTypeResolverBuilder.[-]Add support for final/Kotlin classes in GenericJackson2JsonRedisSerializer [DATAREDIS-995][/-][+]Add support for final/Kotlin classes in `GenericJackson2JsonRedisSerializer` [DATAREDIS-995][/+]Retain target type hint when deserializing Stream records.
Lookup jackson config to figure out what to do with certain types (eg…
Switch Jackson default mapping default from `NON_FINAL` to `EVERYTHING`.