get returns a value of the superclass ArrayList in

2019-06-27 09:45发布

问题:

I have a serialization problem with hazelcast 3.5:

When one hazelcast client(Java) puts a value of class

public class MyType extends ArrayList<MyElem>

into a map, and afterwards another client (other Java process) retrieves the value, it gets back a value of class ArrayList, not the expected subclass MyType!

In hazelcast version 3.1.3 this worked fine: the second client retrieved a value of the correct subclass MyType.

I used the sample configuration hazelcast.xml and the start script server.bat in both hazelcast versions.

Is this possibly a bug in the new 3.5 version?

My client configuration is empty.

回答1:

Hazelcast (I guess it was) 3.4 added a specialized serializer for List subclasses. You have to register a custom serializer to pick up your type. You can subclass the Hazelcast internal serializer and just exchange the factory and type ids you make it uniquely identified.