Closed nicreve closed 3 years ago
@nicreve: Good catch!
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.
Merged. Please verify the fix against the latest SNAPSHOT.
Merged. Please verify the fix against the latest SNAPSHOT.
Thanks, I will verify the fix next week.
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.