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
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.
I saw this error because of a true Java serialization issue; my class definition was not the same on the producer and consumer side (two different applications) and as a result I got this exception.
Just wanted to leave this as an FYI if you hadn't checked that yet.
This happend to me when I used the serializer in multiple threads. It's not thread safe, so if you use it in that way, it may give you "Buffer underflow" or other exceptions.