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 serializing, the entity used has one additional field of type List compared to the entity used for deserialization, which throw an Exception during deserialization. I think the CompatibleFieldSerializer is supposed to handle the addition of new fields, so this situation does not meet expectations.
After briefly examining the Kryo source code, I found that the CollectionSerializer, when serializing, does not write the elementType if it has access to the elementSerializer, and uses kryo.writeObject to write the element. However, during deserialization, kryo.getGenerics().nextGenericClass() returns null and the elementSerializer cannot be obtained, so kryo.readClassAndObject is used to read, which seems to be causing the problem.
To Reproduce
Please delete PoJo.list when deserializing
// KryoFactorypublicclassCompatibleKryoFactory {
privatestaticfinalintMAX_CAPACITY = 8;
privatefinalPool<Kryo> kryoPool;
/** * using zero args constructor as default * if not exists, fallback using ASM */privatestaticfinalInstantiatorStrategySTRATEGY =
newDefaultInstantiatorStrategy(newStdInstantiatorStrategy());
publicCompatibleKryoFactory() {
kryoPool = newPool<Kryo>(true, true, MAX_CAPACITY) {
@OverrideprotectedKryocreate() {
Kryokryo = newKryo();
init(kryo);
returnkryo;
}
};
}
publicKryoobtain() {
returnkryoPool.obtain();
}
publicvoidfree(Kryokryo) {
kryoPool.free(kryo);
}
protectedvoidinit(Kryokryo) {
kryo.setReferences(false);
kryo.setRegistrationRequired(false);
kryo.setInstantiatorStrategy(STRATEGY);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
}
}
Can you test if the problem goes away with chunked encoding?
You could also try disabling generics optimization with kryo.setOptimizedGenerics(false);.
This is definitely a bug, but one that is difficult to resolve and that I already spent a couple of hours on in the past without success. I can't spend any more time on this at the moment but I'd be happy to accept a pull request.
Can you test if the problem goes away with chunked encoding?
You could also try disabling generics optimization with kryo.setOptimizedGenerics(false);.
This is definitely a bug, but one that is difficult to resolve and that I already spent a couple of hours on in the past without success. I can't spend any more time on this at the moment but I'd be happy to accept a pull request.
Thanks for help. Chunked Encoding is useless, but kryo.setOptimizedGenerics(false) is useful.
Describe the bug
When serializing, the entity used has one additional field of type List compared to the entity used for deserialization, which throw an Exception during deserialization. I think the CompatibleFieldSerializer is supposed to handle the addition of new fields, so this situation does not meet expectations.
After briefly examining the Kryo source code, I found that the CollectionSerializer, when serializing, does not write the elementType if it has access to the elementSerializer, and uses kryo.writeObject to write the element. However, during deserialization, kryo.getGenerics().nextGenericClass() returns null and the elementSerializer cannot be obtained, so kryo.readClassAndObject is used to read, which seems to be causing the problem.
To Reproduce
Please delete PoJo.list when deserializing
Environment:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: