文章目录
报错全称代码疑似产生的原因弯路、坑分析解决方案报错全称
java.io.StreamCorruptedException: invalid stream header: 6F617574at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:866)at java.io.ObjectInputStream.<init>(ObjectInputStream.java:358)
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: 6F617574
代码
Cursor cursor = (Cursor) redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize));...cursor.next() // 这句报错
疑似产生的原因
很明显,解码错误。说明反序列化|解码器和序列化|编码器不匹配,不能前呼后应
弯路、坑
应看清错误详情
分析
存储该值的序列化方式应该和反序列化一致
解决方案
1) 修改redis config。重新设置值,再把值取出来,保持序列化、反序列化对应,成功了。