Skip to content

Add support for final/Kotlin classes in GenericJackson2JsonRedisSerializer [DATAREDIS-995] #1566

Closed

Description

@spring-projects-issues

Sébastien Deleuze opened DATAREDIS-995 and commented

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.

This issue should be fixed at Jackson level


No further details from DATAREDIS-995

Activity

  1. spring-projects-issues commented on Sep 9, 2019

    @spring-projects-issues
    Author

    Sébastien Deleuze commented

    DefaultTyping.EVERYTHING has been added to the upcoming Jackson 2.10 to solve that issue. My proposal is to update Spring Data Redis to use it instead of DefaultTyping.NON_FINAL when Jackson 2.10 is in the classpath, otherwise fallback on DefaultTyping.NON_FINAL. 

    FYI Jackson 2.10 should be here on time for Boot 2.2 GA.

     

     

     

  2. spring-projects-issues commented on Sep 27, 2019

    @spring-projects-issues
    Author

    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.EVERYTHING in order to solve this blocking issue that impacts Kotlin developers?

  3. azizabah commented on Jan 10, 2022

    @azizabah

    @mp911de / @sdeleuze - Is this still open? If so, is there a recommended work-around for Kotlin?

  4. mp911de commented on Jan 10, 2022

    @mp911de
    Member

    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.

  5. azizabah commented on Jan 10, 2022

    @azizabah

    @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.

  6. christophstrobl commented on Jan 13, 2022

    @christophstrobl
    Member

    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.

  7. 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
  8. added this to the 2.7 M1 (2021.2.0) milestone on Jan 13, 2022
  9. added a commit that references this issue on Apr 26, 2024
    93c25b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions