Skip to content

The implementation of GenericJackson2JsonRedisSerializer has changed in a non-back-compatible manner - and perhaps, by accident? #2396

Closed
@oliverlockwood

Description

@oliverlockwood

Context

We make significant use of Redis across our microservices platform, including spring-data-redis.
We are in the process of upgrading from Spring-Boot 2.6.x to Spring-Boot 2.7.x.

As a consequence, we have started to see exceptions being thrown when one microservice tries to deserialize data that had been serialised by another microservice running a different spring-boot layer. Given that some state is allowed to survive as we upgrade our platform, this poses problems.

Investigation

After a little investigation, it became clear that the 2.7.x spring-data-redis has fundamentally changed the implementation of the GenericJackson2JsonRedisSerializer class. One example is serialization of a java.util.UUID, where a UUID like 730145fe-324d-4fb1-b12f-60b89a045730:

  1. used to be serialized - as one might expect, for JSON! - as "730145fe-324d-4fb1-b12f-60b89a045730"
  2. from Spring-Boot 2.7.x, the same UUID gets serialized as a strange array, that looks like ["java.util.UUID","730145fe-324d-4fb1-b12f-60b89a045730"]

I looked into the history of the GenericJackson2JsonRedisSerializer class and found commit 0e23a80 which is described as fixing issue #2361. That issue, in turn, is titled:

GenericJackson2JsonRedisSerializer fails with Unexpected token when deserializing int[] with default typing

It strikes me as possible that this change, intended to address problems with the (de)serialization of arrays, has inadvertently caused things that aren't arrays to be serialised as arrays.

If the change is deliberate, is there any reference documentation I can take a look at, to understand why this change has been made - and what else the change has done, which I might not yet have realised?

I would very much welcome some feedback on this issue. Thank you for your time.

Example

An example repo demonstrating the issue is available at https://github.com/oliverlockwood/sb2.7-spring-data-redis-example.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions