使用redis的incrby方法可以设置值,但是取值的时候反序列化异常

Blade 未结 3 1914
xxxing007
xxxing007 2021-07-17 11:09

一、该问题的重现步骤是什么?


bladeRedis.hIncrBy(key, hashKey, 2);    // 第一次redis值为正常2
Integer value = redis.hGet(key, hashKey);  // 取值报错,反序列化异常

// 堆栈信息如下:
java.lang.RuntimeException: Truncated.
at io.protostuff.IOUtil.mergeFrom(IOUtil.java:50)
at io.protostuff.ProtostuffIOUtil.mergeFrom(ProtostuffIOUtil.java:104)
at org.springblade.core.redis.serializer.ProtoStuffSerializer.deserialize(ProtoStuffSerializer.java:59)
at org.springframework.data.redis.core.AbstractOperations.deserializeHashValue(AbstractOperations.java:355)
at org.springframework.data.redis.core.DefaultHashOperations.get(DefaultHashOperations.java:55)

Caused by: io.protostuff.ProtobufException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either than the input has been truncated or that an embedded message misreported its own length.
at io.protostuff.ProtobufException.truncatedMessage(ProtobufException.java:76)
... 123 common frames omitted
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at io.protostuff.ByteArrayInput.readRawVarint32(ByteArrayInput.java:531)
at io.protostuff.ByteArrayInput.skipField(ByteArrayInput.java:179)
at io.protostuff.ByteArrayInput.handleUnknownField(ByteArrayInput.java:217)
at io.protostuff.runtime.RuntimeSchema.mergeFrom(RuntimeSchema.java:462)
at io.protostuff.IOUtil.mergeFrom(IOUtil.java:45)
... 122 common frames omitted


二、你期待的结果是什么?实际看到的又是什么?

期待 value 返回 2,实际报错


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

BladeX

四、请提供详细的错误堆栈信息,这很重要。

java.lang.RuntimeException: Truncated.
at io.protostuff.IOUtil.mergeFrom(IOUtil.java:50)
at io.protostuff.ProtostuffIOUtil.mergeFrom(ProtostuffIOUtil.java:104)
at org.springblade.core.redis.serializer.ProtoStuffSerializer.deserialize(ProtoStuffSerializer.java:59)
at org.springframework.data.redis.core.AbstractOperations.deserializeHashValue(AbstractOperations.java:355)
at org.springframework.data.redis.core.DefaultHashOperations.get(DefaultHashOperations.java:55)

Caused by: io.protostuff.ProtobufException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either than the input has been truncated or that an embedded message misreported its own length.
at io.protostuff.ProtobufException.truncatedMessage(ProtobufException.java:76)
... 123 common frames omitted
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at io.protostuff.ByteArrayInput.readRawVarint32(ByteArrayInput.java:531)
at io.protostuff.ByteArrayInput.skipField(ByteArrayInput.java:179)
at io.protostuff.ByteArrayInput.handleUnknownField(ByteArrayInput.java:217)
at io.protostuff.runtime.RuntimeSchema.mergeFrom(RuntimeSchema.java:462)
at io.protostuff.IOUtil.mergeFrom(IOUtil.java:45)
... 122 common frames omitted


五、若有更多详细信息,请在下面提供。

  1. 不止是 hIncrBy() 之后 hGet() 会报错,其他类型 incrBy() 都会报错

  2. 将序列化方式改为JDK序列化,同样报错,仅堆栈信息不一致

blade.redis.serializer-type=JDK


3条回答
  •  曾远征
    曾远征 (楼主)
    2021-09-24 15:33

    我也是相同的問題,能不能幫忙提供一個解決的方法

提交回复