Program: 49156
Project: 49156
Buggy source:
@Test @ClientCompatibleTest public void testLatchMigration() throws InterruptedException {
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(5);
  HazelcastInstance hz1=factory.newHazelcastInstance(new Config());
  HazelcastInstance hz2=factory.newHazelcastInstance(new Config());
  final ICountDownLatch latch1=hz1.getCountDownLatch("String_Node_Str");
  latch1.trySetCount(10);
  Thread.sleep(100);
  final ICountDownLatch latch2=hz2.getCountDownLatch("String_Node_Str");
  Assert.assertEquals(10,latch2.getCount());
  latch2.countDown();
  Assert.assertEquals(9,latch1.getCount());
  hz1.getLifecycleService().shutdown();
  Assert.assertEquals(9,latch2.getCount());
  HazelcastInstance hz3=factory.newHazelcastInstance(new Config());
  final ICountDownLatch latch3=hz3.getCountDownLatch("String_Node_Str");
  latch3.countDown();
  Assert.assertEquals(8,latch3.getCount());
  hz2.getLifecycleService().shutdown();
  latch3.countDown();
  Assert.assertEquals(7,latch3.getCount());
  HazelcastInstance hz4=factory.newHazelcastInstance(new Config());
  HazelcastInstance hz5=factory.newHazelcastInstance(new Config());
  Thread.sleep(250);
  hz3.getLifecycleService().shutdown();
  final ICountDownLatch latch4=hz4.getCountDownLatch("String_Node_Str");
  Assert.assertEquals(7,latch4.getCount());
  final ICountDownLatch latch5=hz5.getCountDownLatch("String_Node_Str");
  latch5.countDown();
  Assert.assertEquals(6,latch5.getCount());
  latch5.countDown();
  Assert.assertEquals(5,latch4.getCount());
  Assert.assertEquals(5,latch5.getCount());
}

Fixed version (ground truth):
@Test @ClientCompatibleTest public void testLatchMigration() throws InterruptedException {
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(5);
  HazelcastInstance hz1=factory.newHazelcastInstance(new Config());
  HazelcastInstance hz2=factory.newHazelcastInstance(new Config());
  warmUpPartitions(hz2,hz1);
  final ICountDownLatch latch1=hz1.getCountDownLatch("String_Node_Str");
  latch1.trySetCount(10);
  Thread.sleep(500);
  final ICountDownLatch latch2=hz2.getCountDownLatch("String_Node_Str");
  Assert.assertEquals(10,latch2.getCount());
  latch2.countDown();
  Assert.assertEquals(9,latch1.getCount());
  hz1.getLifecycleService().shutdown();
  Assert.assertEquals(9,latch2.getCount());
  HazelcastInstance hz3=factory.newHazelcastInstance(new Config());
  warmUpPartitions(hz3);
  final ICountDownLatch latch3=hz3.getCountDownLatch("String_Node_Str");
  latch3.countDown();
  Assert.assertEquals(8,latch3.getCount());
  hz2.getLifecycleService().shutdown();
  latch3.countDown();
  Assert.assertEquals(7,latch3.getCount());
  HazelcastInstance hz4=factory.newHazelcastInstance(new Config());
  HazelcastInstance hz5=factory.newHazelcastInstance(new Config());
  warmUpPartitions(hz5,hz4);
  Thread.sleep(250);
  hz3.getLifecycleService().shutdown();
  final ICountDownLatch latch4=hz4.getCountDownLatch("String_Node_Str");
  Assert.assertEquals(7,latch4.getCount());
  final ICountDownLatch latch5=hz5.getCountDownLatch("String_Node_Str");
  latch5.countDown();
  Assert.assertEquals(6,latch5.getCount());
  latch5.countDown();
  Assert.assertEquals(5,latch4.getCount());
  Assert.assertEquals(5,latch5.getCount());
}