2

We are using RedisTemplate to get all the keys from a Redis cache. We are using "scan" to get all the keys. We don't use directly Lettuce or Jedis, we let RedisTemplate to do it.

When we configure RedisTemplate to use Lettuce, the scan command returns all the keys. When we configure RedisTemplate to use Jedis, something is wrong and we are seeing the following Exception:

    05-20@22:40:01 ERROR ( MyCache.java:58)     - Exception
org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header: EFBFBDEF
    at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:82)
    at test.MyCache.deserializeKeys(MyCache.java:70)
    at test.MyCache.getKeys(MyCache.java:52)
    at test.RedisApp.main(RedisApp.java:54)
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header: EFBFBDEF
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:78)
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:36)
    at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:80)
    ... 3 more
Caused by: java.io.StreamCorruptedException: invalid stream header: EFBFBDEF
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:808)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
    at org.springframework.core.ConfigurableObjectInputStream.<init>(ConfigurableObjectInputStream.java:63)
    at org.springframework.core.ConfigurableObjectInputStream.<init>(ConfigurableObjectInputStream.java:49)
    at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:68)
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:73)
    ... 5 more

We wanted to ilustrate the problem with a complete example, so we have created a sample project on GitHub https://github.com/michaelweber2/redis-app . This project is using Java 8, Maven (3+), Spring Data Redis (1.8.3.RELEASE), Lettuce (4.3.1.Final) and Jedis (2.9.0). This project was tested with Redis server 3.2.9.

So the question is why do we get this Exception only when we configure RedisTemplate to use Jedis and what can we do to make Jedis work?

Michael W
  • 21
  • 3
  • Seems you have data in your Redis server, some key containing `EFBFBDEF` in its name. Run a Redis `FLUSHALL` command to wipe your Redis data and retry. – mp911de May 22 '17 at 20:49
  • That is not the case. I have configured Redis to keep the entries only in memory. Every time I restart Redis I get fresh one, with no entries. Apart from that I have set up the log level to "debug", so I am watching also what Redis is writing in the logs "0 keys, etc, etc". But thank you for your answer. – Michael W May 23 '17 at 12:51

0 Answers0