Program: 46756
Project: 46756
Buggy source:
@Test public void testPutIfAbsentCacheMergePolicy(){
  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,PutIfAbsentCacheMergePolicy.class.getName());
  Cache cache1=cacheManager1.createCache(cacheName,cacheConfig);
  Cache cache2=cacheManager2.createCache(cacheName,cacheConfig);
  cache1.put("String_Node_Str","String_Node_Str");
  cache2.put("String_Node_Str","String_Node_Str");
  cache2.put("String_Node_Str","String_Node_Str");
  assertOpenEventually(lifeCycleListener.latch);
  assertClusterSizeEventually(2,h1);
  assertClusterSizeEventually(2,h2);
  Cache cacheTest=cacheManager2.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 testPutIfAbsentCacheMergePolicy(){
  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,PutIfAbsentCacheMergePolicy.class.getName());
  Cache cache1=cacheManager1.createCache(cacheName,cacheConfig);
  Cache cache2=cacheManager2.createCache(cacheName,cacheConfig);
  cache1.put("String_Node_Str","String_Node_Str");
  cache2.put("String_Node_Str","String_Node_Str");
  cache2.put("String_Node_Str","String_Node_Str");
  mergeBlockingLatch.countDown();
  assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
  assertClusterSizeEventually(2,h1);
  assertClusterSizeEventually(2,h2);
  Cache cacheTest=cacheManager2.getCache(cacheName);
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
  assertEquals("String_Node_Str",cacheTest.get("String_Node_Str"));
}