Ignore type in the MessageJacksonDeserializer

The `GenericJackson2JsonRedisSerializer` now resolves the target type
before calling `ObjectMapper.readValue()` causing a `ClassCast` in the
`StdNodeBasedDeserializer.deserializeWithType()`

* Override `MessageJacksonDeserializer.deserializeWithType()` with delegating
to the plain `deserialize()` ignoring the `TypeDeserializer`

Related to https://github.com/spring-projects/spring-data-redis/issues/2322
This commit is contained in:
Artem Bilan
2022-09-01 11:40:34 -04:00
parent ccf41d1480
commit 80eea1508e
2 changed files with 11 additions and 6 deletions

View File

@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.JacksonObjectWriter;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.history.MessageHistory;
@@ -185,10 +184,7 @@ class RedisChannelMessageStoreTests implements RedisContainerTest {
void testJsonSerialization() {
RedisChannelMessageStore store = new RedisChannelMessageStore(RedisContainerTest.connectionFactory());
ObjectMapper mapper = JacksonJsonUtils.messagingAwareMapper();
GenericJackson2JsonRedisSerializer serializer =
new GenericJackson2JsonRedisSerializer(mapper,
(mapper1, source, type) -> mapper1.readValue(source, Object.class),
JacksonObjectWriter.create());
GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer(mapper);
store.setValueSerializer(serializer);
Message<?> genericMessage = new GenericMessage<>(new Date());