Program: 49680
Project: 49680
Buggy source:
@Test public void testMigrationOfTTLAndLock() throws Exception {
  Config config=new Config();
  final HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  final HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  ConcurrentMapManager cmm1=getConcurrentMapManager(h1);
  ConcurrentMapManager cmm2=getConcurrentMapManager(h2);
  final IMap imap1=h1.getMap("String_Node_Str");
  final IMap imap2=h2.getMap("String_Node_Str");
  final Data dKey=toData("String_Node_Str");
  assertTrue(migrateKey("String_Node_Str",h1,h1,0));
  assertTrue(migrateKey("String_Node_Str",h1,h2,1));
  imap1.put("String_Node_Str","String_Node_Str",60,TimeUnit.SECONDS);
  imap1.lock("String_Node_Str");
  Future put2=imap2.putAsync("String_Node_Str","String_Node_Str");
  imap2.addEntryListener(new EntryAdapter(){
    @Override public void entryUpdated(    EntryEvent entryEvent){
      System.out.println(entryEvent);
    }
  }
,"String_Node_Str",true);
  if (put2 == null)   fail();
  Thread.sleep(1000);
  CMap cmap1=getCMap(h1,"String_Node_Str");
  CMap cmap2=getCMap(h2,"String_Node_Str");
  Record record1=cmap1.getRecord(dKey);
  assertEquals(1,record1.getScheduledActionCount());
  for (  ScheduledAction scheduledAction : record1.getScheduledActions()) {
    assertTrue(scheduledAction.isValid());
  }
  assertNotNull(record1.getListeners());
  assertEquals(1,record1.getListeners().size());
  DistributedLock lock=cmap1.getRecord(dKey).getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  assertTrue(migrateKey("String_Node_Str",h1,h2,0));
  assertTrue(migrateKey("String_Node_Str",h1,h1,1));
  Thread.sleep(1000);
  cmap1.startCleanup(true);
  cmap2.startCleanup(true);
  assertEquals(1,cmap1.mapRecords.size());
  assertEquals(1,cmap2.mapRecords.size());
  assertEquals(1,cmap2.getMapIndexService().getOwnedRecords().size());
  assertEquals(0,cmap1.getMapIndexService().getOwnedRecords().size());
  assertTrue(cmap1.getRecord(dKey).getRemainingTTL() < 60000);
  assertTrue(cmap2.getRecord(dKey).getRemainingTTL() < 60000);
  Record record2=cmap2.getRecord(dKey);
  lock=record2.getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  lock=cmap1.getRecord(dKey).getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  imap1.unlock("String_Node_Str");
  put2.get(10,TimeUnit.SECONDS);
  assertEquals("String_Node_Str",imap1.get("String_Node_Str"));
  assertEquals("String_Node_Str",imap2.get("String_Node_Str"));
  assertNotNull(record2.getListeners());
  assertEquals(1,record2.getListeners().size());
}

Fixed version (ground truth):
@Test public void testMigrationOfTTLAndLock() throws Exception {
  Config config=new Config();
  final HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  final HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  ConcurrentMapManager cmm1=getConcurrentMapManager(h1);
  ConcurrentMapManager cmm2=getConcurrentMapManager(h2);
  final IMap imap1=h1.getMap("String_Node_Str");
  final IMap imap2=h2.getMap("String_Node_Str");
  final Data dKey=toData("String_Node_Str");
  assertTrue(migrateKey("String_Node_Str",h1,h1,0));
  assertTrue(migrateKey("String_Node_Str",h1,h2,1));
  imap1.put("String_Node_Str","String_Node_Str",60,TimeUnit.SECONDS);
  imap1.lock("String_Node_Str");
  Future put2=imap2.putAsync("String_Node_Str","String_Node_Str");
  imap2.addEntryListener(new EntryAdapter(){
    @Override public void entryUpdated(    EntryEvent entryEvent){
      System.out.println(entryEvent);
    }
  }
,"String_Node_Str",true);
  if (put2 == null)   fail();
  Thread.sleep(1000);
  CMap cmap1=getCMap(h1,"String_Node_Str");
  CMap cmap2=getCMap(h2,"String_Node_Str");
  Record record1=cmap1.getRecord(dKey);
  assertEquals(1,record1.getScheduledActionCount());
  for (  ScheduledAction scheduledAction : record1.getScheduledActions()) {
    assertTrue(scheduledAction.isValid());
  }
  assertNotNull(record1.getListeners());
  assertEquals(1,record1.getListeners().size());
  DistributedLock lock=cmap1.getRecord(dKey).getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  assertEquals(1,cmap1.mapRecords.size());
  assertEquals(1,cmap2.mapRecords.size());
  assertEquals(0,cmap2.getMapIndexService().getOwnedRecords().size());
  assertEquals(1,cmap1.getMapIndexService().getOwnedRecords().size());
  assertTrue(migrateKey("String_Node_Str",h1,h2,0));
  assertTrue(migrateKey("String_Node_Str",h1,h1,1));
  assertEquals(1,cmap1.mapRecords.size());
  assertEquals(1,cmap2.mapRecords.size());
  assertEquals(0,cmap1.getMapIndexService().getOwnedRecords().size());
  assertEquals(1,cmap2.getMapIndexService().getOwnedRecords().size());
  assertTrue(cmap1.getRecord(dKey).getRemainingTTL() < 60000);
  assertTrue(cmap2.getRecord(dKey).getRemainingTTL() < 60000);
  Record record2=cmap2.getRecord(dKey);
  lock=record2.getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  lock=cmap1.getRecord(dKey).getLock();
  assertTrue(cmm1.thisAddress.equals(lock.getLockAddress()));
  assertTrue(lock.getLockThreadId() != -1);
  assertEquals(1,lock.getLockCount());
  imap1.unlock("String_Node_Str");
  put2.get(10,TimeUnit.SECONDS);
  assertEquals("String_Node_Str",imap1.get("String_Node_Str"));
  assertEquals("String_Node_Str",imap2.get("String_Node_Str"));
  assertNotNull(record2.getListeners());
  assertEquals(1,record2.getListeners().size());
}