altoo-ag/akka-kryo-serialization

tags not recognized in com.esotericsoftware.kryo.serializers.TaggedFieldSerializer

Zhen-hao opened this issue · 3 comments

in the logs I see:

I have a class defined as

  case class MyEvent(@Tag(0) filed1: Array[Byte], @Tag(1) field2: Array[Byte]) extends Event

and registered it as follows:

kryo.register(classOf[MyEvent], 101)

persisting works well.
but when the actors are recovering, I see the following in the logs:

00:01 TRACE: [kryo] Field filed1: class [B
00:01 TRACE: [kryo] Field filed1: class [B
00:01 TRACE: [kryo] Field filed1: class [B
00:01 TRACE: [kryo] Field filed1: class [B
00:01 TRACE: [kryo] Field field2: class [B
00:01 TRACE: [kryo] Field field2: class [B
00:01 TRACE: [kryo] Field field2: class [B
00:01 TRACE: [kryo] Field field2: class [B
00:01 TRACE: [kryo] Ignoring field without tag: field2
00:01 TRACE: [kryo] Ignoring field without tag: field2
00:01 TRACE: [kryo] Ignoring field without tag: field2
00:01 TRACE: [kryo] Ignoring field without tag: field2
00:01 TRACE: [kryo] Ignoring field without tag: filed1
00:01 TRACE: [kryo] Ignoring field without tag: filed1
00:01 TRACE: [kryo] Ignoring field without tag: filed1
00:01 TRACE: [kryo] Ignoring field without tag: filed1
...
00:01 DEBUG: [kryo] Read: MyEvent(null,null)
00:01 DEBUG: [kryo] Read: MyEvent(null,null)
...

Am I doing something totally wrong?

I figured out the cause of it.
If I use CompatibleFieldSerializer instead of TaggedFieldSerializer, I will see the following in the logs/

Class is not registered: byte[]
...
Note: To register this class use: kryo.register(byte[].class);

So it is obviously caused by not registering the Array[Byte] type.
But why the error message is missing in CompatibleFieldSerializer?

Glad you could figure it out. I was trying to write a simple test to check it out had some JDK related issues... Anyway, without looking further into it I guess that behaviour is from Kryo itself and probably has to be addressed there.
But good to know that errors might not be visible with the TaggedFieldSerializer.

actually registering Array[Byte] doesn't change the behavior of CompatibleFieldSerializer.
It is very strange. I will look into the Kryo library later when I have time.
For now, I will just use other classes.
Feel free to close it.