Program: 46755
Project: 46755
Buggy source:
@Test public void testLatestAccessCacheMergePolicy(){
  String cacheName=randomMapName();
  Config config=newConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  TestMemberShipListener memberShipListener=new TestMemberShipListener(1);
  h2.getCluster().addMembershipListener(memberShipListener);
  TestLifeCycleListener lifeCycleListener=new TestLifeCycleListener(1);
  h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
  closeConnectionBetween(h1,h2);
  assertOpenEventually(memberShipListener.latch);
  assertClusterSizeEventually(1,h1);
  assertClusterSizeEventually(1,h2);
  CachingProvider cachingProvider1=HazelcastServerCachingProvider.createCachingProvider(h1);
  CachingProvider cachingProvider2=HazelcastServerCachingProvider.createCachingProvider(h2);
  CacheManager cacheManager1=cachingProvider1.getCacheManager();
  CacheManager cacheManager2=cachingProvider2.getCacheManager();
  CacheConfig cacheConfig=newCacheConfig(cacheName,LatestAccessCacheMergePolicy.class.getName());
  Cache cache1=cacheManager1.createCache(cacheName,cacheConfig);
  Cache cache2=cacheManager2.createCache(cacheName,cacheConfig);
  cache1.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache1.get("String_Node_Str"));
  sleepAtLeastMillis(1);
  cache2.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache2.get("String_Node_Str"));
  cache2.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache2.get("String_Node_Str"));
  sleepAtLeastMillis(1);
  cache1.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache1.get("String_Node_Str"));
  assertOpenEventually(lifeCycleListener.latch);
  assertClusterSizeEventually(2,h1);
  assertClusterSizeEventually(2,h2);
  Cache cacheTest=cacheManager1.getCache(cacheName);
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testLatestAccessCacheMergePolicy(){
  String cacheName=randomMapName();
  Config config=newConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  warmUpPartitions(h1,h2);
  TestMemberShipListener memberShipListener=new TestMemberShipListener(1);
  h2.getCluster().addMembershipListener(memberShipListener);
  CountDownLatch mergeBlockingLatch=new CountDownLatch(1);
  TestLifeCycleListener lifeCycleListener=new TestLifeCycleListener(1,mergeBlockingLatch);
  h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
  closeConnectionBetween(h1,h2);
  assertOpenEventually(memberShipListener.memberRemovedLatch);
  assertClusterSizeEventually(1,h1);
  assertClusterSizeEventually(1,h2);
  CachingProvider cachingProvider1=HazelcastServerCachingProvider.createCachingProvider(h1);
  CachingProvider cachingProvider2=HazelcastServerCachingProvider.createCachingProvider(h2);
  CacheManager cacheManager1=cachingProvider1.getCacheManager();
  CacheManager cacheManager2=cachingProvider2.getCacheManager();
  CacheConfig cacheConfig=newCacheConfig(cacheName,LatestAccessCacheMergePolicy.class.getName());
  Cache cache1=cacheManager1.createCache(cacheName,cacheConfig);
  Cache cache2=cacheManager2.createCache(cacheName,cacheConfig);
  cache1.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache1.get("String_Node_Str"));
  sleepAtLeastMillis(1);
  cache2.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache2.get("String_Node_Str"));
  cache2.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache2.get("String_Node_Str"));
  sleepAtLeastMillis(1);
  cache1.put("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",cache1.get("String_Node_Str"));
  mergeBlockingLatch.countDown();
  assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
  assertClusterSizeEventually(2,h1);
  assertClusterSizeEventually(2,h2);
  Cache cacheTest=cacheManager1.getCache(cacheName);
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
}