You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When serialize then deserialize this class with CompatiableFieldSerializer, we encountered this exception:
Caused by: com.esotericsoftware.kryo.KryoException: Read type is incompatible with the field type: com.esotericsoftware.kryo.serializers.ClosureSerializer$Closure -> com.esotericsoftware.kryo.serializers.ClosureSerializer$Closure (com.xxx.TestClass#callback)
I believe it's because CompatiableFieldSerializer cached the field's value class (set to TestClass#callback) during serialization, but the actual output content is ClosureSerializer$Closure. Then during deserialization, it's mismatched. To Reproduce
Use CompatiableFieldSerializer to serialize a class with lambda field(s), then deserialize it.
Environment:
OS: Ubuntu 20.04
JDK Version: 8
Kryo Version: 5.0.4
Additional context
I switch to FieldSerializer it works fine, but I didn't test TaggedFieldSerializer and VersionFieldSerializer.
The text was updated successfully, but these errors were encountered:
The type validation in CompatibleFieldSerializer currently fails for lambdas because they are serialized using a marker type ClosureSerializer$Closure. I created a PR that adds an additional check for this marker interface. It works, but it is not safe, because we do not know if the serialized lambda really is assignable to the given type. I'll think about it some more, but I'll apply the PR if I can't come up with a better solution.
Describe the bug
We have a class with a field to store lambda, the field's class is a functional interface, something like this:
When serialize then deserialize this class with CompatiableFieldSerializer, we encountered this exception:
I believe it's because CompatiableFieldSerializer cached the field's value class (set to TestClass#callback) during serialization, but the actual output content is ClosureSerializer$Closure. Then during deserialization, it's mismatched.
To Reproduce
Use CompatiableFieldSerializer to serialize a class with lambda field(s), then deserialize it.
Environment:
Additional context
I switch to FieldSerializer it works fine, but I didn't test TaggedFieldSerializer and VersionFieldSerializer.
The text was updated successfully, but these errors were encountered: