Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Java Collections default serializers #15371

Merged
merged 11 commits into from Aug 2, 2019

Conversation

@ihsandemir
Copy link
Contributor

ihsandemir commented Jul 24, 2019

Added the following Java default serializers.

  1. ArrayDeque
  2. HashSet
  3. TreeSet
  4. TreeMap
  5. LinkedHashSet
  6. LinkedHashMap
  7. LinkedBlockingQueue
  8. ArrayBlockingQueue
  9. PriorityBlockingQueue
  10. DelayQueue
  11. SynchronousQueue
  12. LinkedBlockingDeque
  13. LinkedTransferQueue
  14. CopyOnWriteArrayList
  15. CopyOnWriteArraySet
  16. ConcurrentSkipListSet
  17. ConcurrentHashMap
  18. ConcurrentSkipListMap
@ihsandemir ihsandemir added this to the 4.0 milestone Jul 24, 2019
@ihsandemir ihsandemir requested review from sancar and asimarslan Jul 24, 2019
@ihsandemir ihsandemir self-assigned this Jul 24, 2019
@@ -181,6 +184,10 @@ private void registerJavaTypeSerializers() {
registerConstant(Enum.class, new EnumSerializer());
registerConstant(ArrayList.class, new ArrayListStreamSerializer());
registerConstant(LinkedList.class, new LinkedListStreamSerializer());
MapStreamSerializer mapSerializer = new MapStreamSerializer();
registerConstant(HashMap.class, mapSerializer);
registerConstant(ConcurrentHashMap.class, mapSerializer);

This comment has been minimized.

Copy link
@sancar

sancar Jul 25, 2019

Member

If we want to guarantee the type will be same also, using the same serializer will not work.
ArrayList and LinkedList serializer are different because of that.
That being said, we may reconsider the concurrent List type support also. Having to register all concrete types does not seem maintainable to me.
Why can't we just register Map.class, List.class ?

This comment has been minimized.

Copy link
@mmedenjak

mmedenjak Jul 25, 2019

Contributor

My 2 cents - we can support only the main couple of implementations. The user can always add custom serialisation for any non-typical collection implementation but I still think that if I provide a ConcurrentHashMap while serialising, I would expect the same when deserialising (otherwise subtle concurrency bugs may arise).

@mmedenjak

This comment has been minimized.

Copy link
Contributor

mmedenjak commented Jul 25, 2019

I think this PR fixes #634, maybe you can double-check.

@sancar
sancar approved these changes Jul 25, 2019
@sancar

This comment has been minimized.

Copy link
Member

sancar commented Jul 25, 2019

How about all following implementations provided by java ? Should we register them all.

ArrayDeque
HashSet
TreeSet
TreeMap
LinkedHashSet
LinkedHashMap
LinkedBlockingQueue
ArrayBlockingQueue
PriorityBlockingQueue
DelayQueue
SynchronousQueue
LinkedBlockingDeque
LinkedTransferQueue
CopyOnWriteArrayList
CopyOnWriteArraySet
ConcurrentSkipListSet
ConcurrentHashMap
ConcurrentSkipListMap
@mmedenjak

This comment has been minimized.

Copy link
Contributor

mmedenjak commented Jul 25, 2019

Hm, the list is a bit longer than I expected :) But I would say, if it's not a big problem, I'd prefer if we added support for all. If it's a problem, maybe we can skip Queue implementations.

@sancar

This comment has been minimized.

Copy link
Member

sancar commented Jul 25, 2019

I don't think it is a problem. I am in favor of registering them all.

@ihsandemir

This comment has been minimized.

Copy link
Contributor Author

ihsandemir commented Jul 26, 2019

@sancar and @mmedenjak I added all the list of collections and did the necessary fixes. Can you review again please?

@sancar
sancar approved these changes Jul 26, 2019
@ihsandemir ihsandemir changed the title Add Map and Set default Java serializers Add Java Collections default serializers Jul 31, 2019
Copy link
Contributor

mmedenjak left a comment

Looks good, thank you for adding support for all collections!

import java.util.concurrent.ConcurrentSkipListMap;

/**
* The {@link AbstractMapStreamSerializer} serializer

This comment has been minimized.

Copy link
@mmedenjak

mmedenjak Jul 31, 2019

Contributor

Minor: fix javadoc

@ihsandemir ihsandemir force-pushed the ihsandemir:containerSerialization branch from 0e08c93 to f8e6626 Aug 1, 2019
@ihsandemir ihsandemir requested a review from sancar Aug 1, 2019
@sancar
sancar approved these changes Aug 2, 2019
@ihsandemir ihsandemir merged commit 528717c into hazelcast:master Aug 2, 2019
1 check passed
1 check passed
default Test PASSed.
Details
@ihsandemir ihsandemir deleted the ihsandemir:containerSerialization branch Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.