hazelcast/hazelcast — pull request #427 by mkarneim (2013-02-28 16:26:46+00:00)
Title: Remove data from map when merge policy returns REMOVE_EXISTING 

Hi,

I patched the com.hazelcast.impl.ConcurrentMapManager.MergeOperationHandler.MergeLoader.doMapStoreOperation() so that it checks if the winner of the merge() call on the active MergePolicy is MergePolicy.REMOVE_EXISTING. If so it removes the object from the map.

I'm not sure if this was a bug. I found it when I implemented a custom merge policy that returned a MergePolicy.REMOVE_EXISTING object. When it was executed I got a strange serialization exception that says that the REMOVE_EXISTING Object was not serializable (which is obviously true). So I checked the Hazelcast code in ConcurrentMapManager and found out, that the merge-method of MergePolicy has 2 call references, of which only one checks if the result is a REMOVE_EXISTING instance. So I patched the other one and tested it. For me that works now.

Cheers,
Michael