Hi All,
I'm relatively new to Kryo, but have already found it very helpful in my project so thanks to all those involved.
Let's say I have a class named Person, and this class has a private field of type org.joda.time.DateTime. If I create a Kryo object, register Person.class, register DateTime.class, and also add a default serializer for DateTime
Setup:
class Person with private field of type org.joda.time.DateTime
Execution:
create Kryo object
set reqistration required
register Person.class
register DateTime.class
add default serializer for DateTime.class (from https://github.com/magro/kryo-serializers/)
When I attempt to write an object of type person, the default field serializer is used, as I would expect. But when the field serializer gets to the DateTime field, instead of using the registered DateTime serializer, it looks through the DateTime class and throws an IllegalArgumentException "Class not registered" when if finds field types that have not been registered (e.g. org.joda.time.chrono.ISOChronology).
I would have expected the serializer I added to be passed the DateTime field for serialization and didn't think the inner types would need to be registered.
So I guess my question is, is this is proscribed behaviour? If I assign a default serializer for a class, do I still need to register it's field types? Or have I likely made an error somewhere (in which case I'll try to cut the code down and paste here).
Thanks in advance for any help
--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
Thanks for the pointer Nate.
Thanks for the pointer Nate.I fixed the problem by adding the DateTime serializer prior to registering DateTime class, but I take your point that I could simply assign the serializer in the register call.I do find the behavior a little non-intuitive though.
I'm assuming (maybe incorrectly) that kryo has an internal Map of class types to serializers. When I callkryo.register(DateTime.clas, #)I presume it puts an entry of DateTime class=FieldSerializer (the default). When I subsequently call:kryo.addDefaultSerializer(DateTime.class, DateTimeSerializer.class)I would expect any existing assignment of DateTime.class=FieldSerializer to be replaced, but this does not appear to be the case and it still uses FieldSerializer on any subsequent attempts to write a DateTime object.