Hello team,
Thank you very much for your efforts, much appreciated.
I believe it would be useful if there was a way to register a custom Kryo serializer.
The use case is case when using Enums for the State or Events.
The default Kryo serializer for Enums does the following:
public void write (Kryo kryo, Output output, Enum object) {
if (object == null) {
output.writeVarInt(NULL, true);
return;
}
output.writeVarInt(object.ordinal() + 1, true);
}
public Enum read (Kryo kryo, Input input, Class<? extends Enum> type) {
int ordinal = input.readVarInt(true);
if (ordinal == NULL) return null;
ordinal--;
if (ordinal < 0 || ordinal > enumConstants.length - 1)
throw new KryoException("Invalid ordinal for enum \"" + type.getName() + "\": " + ordinal);
Object constant = enumConstants[ordinal];
return (Enum)constant;
}
This means that if you modify the Enum (adding or removing states), best case it would throw a KryoException and would not be able to deserialize, worst case the states and event will be mixed up.
Kryo provides a serializer for Enums using the name but there is no way at the moment to access the Kryo instance and configure it.
A good option would be to be able to register a custom Kryo serializer from the configuration.
Hello team, Thank you very much for your efforts, much appreciated. I believe it would be useful if there was a way to register a custom Kryo serializer. The use case is case when using Enums for the State or Events. The default Kryo serializer for Enums does the following:
This means that if you modify the Enum (adding or removing states), best case it would throw a KryoException and would not be able to deserialize, worst case the states and event will be mixed up. Kryo provides a serializer for Enums using the name but there is no way at the moment to access the Kryo instance and configure it. A good option would be to be able to register a custom Kryo serializer from the configuration.
Thanks,