Closed BrotherJing closed 3 years ago
@BrotherJing: Thank you for the detailed bug report!
I'm currently on vacation and won't be able to look into this for a couple of weeks. If you want, you can submit a PR with a fix and I'll merge it.
@BrotherJing: I was able to reproduce your problem and have debugged it for some time but was unable to come up with a solution. The problem seems to be related to references
. If references
are disabled, the data can be read without problems.
I currently don't have the capacity to spend a lot of time on this issue and would greatly appreciate it if someone could look into this and help with fixing the issue.
@theigl, we came across a similar issue, is there more documentation and examples on CompatibleFieldSerializer as it is supposed to be the simplest and most compatible.
https://github.com/EsotericSoftware/kryo#compatiblefieldserializer wiki also has to be updated to readUnknownFieldData default: true. From what I gathered, if we set readUnknownFieldData:true it handle unknown fields and if reading fails due to class removed? chunkedEncoding:true will gracefully skip.
Assuming, most people will use the simplest configuration for CompatibleFieldSerializer to support graceful deserialization with backward/forward compatibility, any idea why this is not a major bug?
CompatibleFieldSerializer.CompatibleFieldSerializerConfig config =
new CompatibleFieldSerializer.CompatibleFieldSerializerConfig();
config.setChunkedEncoding(true);
config.setReadUnknownFieldData(true);
@theigl, we came across a similar issue, is there more documentation and examples on CompatibleFieldSerializer as it is supposed to be the simplest and most compatible.
Apart from the Readme, there is only the JavaDoc for the serializers.
https://github.com/EsotericSoftware/kryo#compatiblefieldserializer wiki also has to be updated to readUnknownFieldData default: true. From what I gathered, if we set readUnknownFieldData:true it handle unknown fields and if reading fails due to class removed? chunkedEncoding:true will gracefully skip.
I added the missing default values to the documentation. Your understanding is correct.
Assuming, most people will use the simplest configuration for CompatibleFieldSerializer to support graceful deserialization with backward/forward compatibility, any idea why this is not a major bug?
What do you mean by "this"? This ticket or that chunkedEncoding
isn't enabled by default?
I'm not the original author of the serializers, but I am pretty sure that chunked encoding is disabled by default, because it has a significant performance overhead and users should opt-in if they really need it.
@BrotherJing: After some more hours of debugging, I managed to get to the bottom of this. Chunked input failed to correctly skip a chunk after a buffer underflow. The underflow is caused by another issue that I cannot fix at this point, but my proposed changes will solve your problem.
@BrotherJing: Please test your issue against the latest Kryo Snapshots.
@BrotherJing , any luck with the latest snapshot?
@theigl, as a follow up from previous discussion, why would this config throw exception when deserializing bytes with a new registered class added? Shouldn't CompatibleFieldSerializer, chunkedEncoding and warnUnregisteredClasses(true) work gracefully?
Kryo kryo = new Kryo();
kryo.setReferences(false);
CompatibleFieldSerializer.CompatibleFieldSerializerConfig config =
new CompatibleFieldSerializer.CompatibleFieldSerializerConfig();
config.setReadUnknownFieldData(true);
config.setChunkedEncoding(true);
kryo.setDefaultSerializer(new SerializerFactory.CompatibleFieldSerializerFactory(config));
kryo.setRegistrationRequired(false); // each class has its own ID
// registered classes must have exact same IDs during deserialization or use "warn" for backward compatibility?
kryo.setWarnUnregisteredClasses(true);
kryo.register(Foo.class, 11);
kryo.register(Bar.class, 12);
Describe the bug Got KryoException: Buffer underflow when I try to deserialize data after remove a field with Collection type from the class.
To Reproduce
First, serialize the original object.
Then, comment field
aaa
, and runGot
FYI, The kryo I use:
Environment:
Additional context Add any other context about the problem here.