Kryo Deserialization fails with “KryoException: Buffer underflow”

前端 未结 3 1570
一向
一向 2021-02-13 07:21

I use Kryo to write Objects into byte arrays. It works fine. But when the byte arrays are converted into the Objects, it throws, com.esotericsoftware.kryo.KryoException: B

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-13 07:46

    This happened to me when I was not correctly closing the Output / Input types. You need to make sure Kryo flushes everything but doing output.flush() or output.close().

    Second, look into kryo.writeClassAndObject(). You can then do kryo.readClassAndObject() and cast your object to the type it is supposed to be.

提交回复
热议问题