Program: 50132
Project: 50132
Buggy source:
@Test public void testTTL() throws Exception {
  Config config=new XmlConfigBuilder().build();
  FactoryImpl mockFactory=mock(FactoryImpl.class);
  Node node=new Node(mockFactory,config);
  node.serviceThread=Thread.currentThread();
  CMap cmap=new CMap(node.concurrentMapManager,"String_Node_Str");
  Object key="String_Node_Str";
  Object value="String_Node_Str";
  Data dKey=toData(key);
  Data dValue=toData(value);
  Request reqPut=newPutRequest(dKey,dValue);
  reqPut.ttl=3000;
  cmap.put(reqPut);
  assertTrue(cmap.mapRecords.containsKey(toData(key)));
  Data actualValue=cmap.get(newGetRequest(dKey));
  assertThat(toObject(actualValue),equalTo(value));
  assertEquals(1,cmap.mapRecords.size());
  Record record=cmap.getRecord(dKey);
  assertNotNull(record);
  assertTrue(record.isActive());
  assertTrue(record.isValid());
  assertEquals(1,cmap.size());
  assertNotNull(cmap.locallyOwnedMap);
  assertNotNull(cmap.get(newGetRequest(dKey)));
  assertEquals(dValue,cmap.get(newGetRequest(dKey)));
  assertEquals(value,cmap.locallyOwnedMap.get(key));
  assertEquals(1,cmap.locallyOwnedMap.mapCache.size());
  Thread.sleep(5000);
  cmap.locallyOwnedMap.evict(System.currentTimeMillis());
  assertEquals(0,cmap.locallyOwnedMap.mapCache.size());
  assertEquals(OBJECT_REDO,cmap.locallyOwnedMap.get(key));
  assertEquals(0,cmap.size());
  assertTrue(cmap.evict(newEvictRequest(dKey)));
  assertTrue(cmap.shouldPurgeRecord(record,System.currentTimeMillis() + 10000));
  cmap.removeAndPurgeRecord(record);
  assertEquals(0,cmap.mapRecords.size());
}

Fixed version (ground truth):
@Test public void testTTL() throws Exception {
  Config config=new Config();
  FactoryImpl mockFactory=mock(FactoryImpl.class);
  Node node=new Node(mockFactory,config);
  node.serviceThread=Thread.currentThread();
  CMap cmap=new CMap(node.concurrentMapManager,"String_Node_Str");
  Object key="String_Node_Str";
  Object value="String_Node_Str";
  Data dKey=toData(key);
  Data dValue=toData(value);
  Request reqPut=newPutRequest(dKey,dValue);
  reqPut.ttl=3000;
  cmap.put(reqPut);
  assertTrue(cmap.mapRecords.containsKey(toData(key)));
  Data actualValue=cmap.get(newGetRequest(dKey));
  assertThat(toObject(actualValue),equalTo(value));
  assertEquals(1,cmap.mapRecords.size());
  Record record=cmap.getRecord(dKey);
  assertNotNull(record);
  assertTrue(record.isActive());
  assertTrue(record.isValid());
  assertEquals(1,cmap.size());
  assertNotNull(cmap.locallyOwnedMap);
  assertNotNull(cmap.get(newGetRequest(dKey)));
  assertEquals(dValue,cmap.get(newGetRequest(dKey)));
  assertEquals(value,cmap.locallyOwnedMap.get(key));
  assertEquals(1,cmap.locallyOwnedMap.mapCache.size());
  assertTrue(record.getRemainingTTL() > 1000);
  Thread.sleep(1000);
  assertTrue(record.getRemainingTTL() < 2001);
  cmap.put(newPutRequest(dKey,dValue));
  assertTrue(record.getRemainingTTL() > 2001);
  assertTrue(record.isActive());
  assertTrue(record.isValid());
  Thread.sleep(1000);
  assertTrue(record.getRemainingTTL() < 2001);
  cmap.put(newPutRequest(dKey,dValue));
  assertTrue(record.getRemainingTTL() > 2001);
  assertTrue(record.isActive());
  assertTrue(record.isValid());
  Thread.sleep(5000);
  cmap.locallyOwnedMap.evict(System.currentTimeMillis());
  assertEquals(0,cmap.locallyOwnedMap.mapCache.size());
  assertEquals(OBJECT_REDO,cmap.locallyOwnedMap.get(key));
  assertEquals(0,cmap.size());
  assertTrue(cmap.evict(newEvictRequest(dKey)));
  assertTrue(cmap.shouldPurgeRecord(record,System.currentTimeMillis() + 10000));
  cmap.removeAndPurgeRecord(record);
  assertEquals(0,cmap.mapRecords.size());
}