Program: 7507
Project: 7507
Buggy source:
@Test public void testCleanup() throws Exception {
  DatasetFramework dsFramework=new InMemoryDatasetFramework(new InMemoryDefinitionRegistryFactory());
  dsFramework.addModule("String_Node_Str",new InMemoryOrderedTableModule());
  CConfiguration cConf=CConfiguration.create();
  Configuration conf=HBaseConfiguration.create();
  cConf.copyTxProperties(conf);
  TransactionManager txManager=new TransactionManager(conf);
  txManager.startAndWait();
  TransactionSystemClient txClient=new InMemoryTxSystemClient(txManager);
  FileMetaDataManager fileMetaDataManager=new FileMetaDataManager(new LogSaverTableUtil(dsFramework,cConf),txClient,locationFactory);
  Location baseDir=locationFactory.create(TEMP_FOLDER.newFolder().toURI());
  long deletionBoundary=System.currentTimeMillis() - RETENTION_DURATION_MS;
  LOG.info("String_Node_Str",deletionBoundary);
  LoggingContext dummyContext=new FlowletLoggingContext("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Location contextDir=baseDir.append("String_Node_Str");
  List<Location> toDelete=Lists.newArrayList();
  for (int i=0; i < 5; ++i) {
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str"));
  }
  Assert.assertFalse(toDelete.isEmpty());
  List<Location> notDelete=Lists.newArrayList();
  for (int i=0; i < 5; ++i) {
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
  }
  Assert.assertFalse(notDelete.isEmpty());
  for (  Location location : toDelete) {
    fileMetaDataManager.writeMetaData(dummyContext,deletionBoundary - RANDOM.nextInt(50000) - 10000,createFile(location));
  }
  for (  Location location : notDelete) {
    fileMetaDataManager.writeMetaData(dummyContext,deletionBoundary + RANDOM.nextInt(50000) + 10000,createFile(location));
  }
  Assert.assertEquals(toDelete.size() + notDelete.size(),fileMetaDataManager.listFiles(dummyContext).size());
  LogCleanup logCleanup=new LogCleanup(fileMetaDataManager,baseDir,RETENTION_DURATION_MS);
  logCleanup.run();
  logCleanup.run();
  for (  Location location : toDelete) {
    Assert.assertFalse("String_Node_Str" + location.toURI() + "String_Node_Str",location.exists());
  }
  for (  Location location : notDelete) {
    Assert.assertTrue("String_Node_Str" + location.toURI() + "String_Node_Str",location.exists());
  }
  for (int i=0; i < 5; ++i) {
    Location delDir=contextDir.append("String_Node_Str" + i);
    Assert.assertFalse("String_Node_Str" + delDir.toURI() + "String_Node_Str",delDir.exists());
  }
}

Fixed version (ground truth):
@Test public void testCleanup() throws Exception {
  DatasetFramework dsFramework=new InMemoryDatasetFramework(new InMemoryDefinitionRegistryFactory());
  dsFramework.addModule("String_Node_Str",new InMemoryOrderedTableModule());
  CConfiguration cConf=CConfiguration.create();
  Configuration conf=HBaseConfiguration.create();
  cConf.copyTxProperties(conf);
  TransactionManager txManager=new TransactionManager(conf);
  txManager.startAndWait();
  TransactionSystemClient txClient=new InMemoryTxSystemClient(txManager);
  FileMetaDataManager fileMetaDataManager=new FileMetaDataManager(new LogSaverTableUtil(dsFramework,cConf),txClient,locationFactory);
  Location baseDir=locationFactory.create(TEMP_FOLDER.newFolder().toURI());
  long deletionBoundary=System.currentTimeMillis() - RETENTION_DURATION_MS;
  LOG.info("String_Node_Str",deletionBoundary);
  LoggingContext dummyContext=new FlowletLoggingContext("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Location contextDir=baseDir.append("String_Node_Str");
  List<Location> toDelete=Lists.newArrayList();
  for (int i=0; i < 5; ++i) {
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    toDelete.add(contextDir.append("String_Node_Str"));
  }
  Assert.assertFalse(toDelete.isEmpty());
  List<Location> notDelete=Lists.newArrayList();
  for (int i=0; i < 5; ++i) {
    toDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
    notDelete.add(contextDir.append("String_Node_Str" + i + "String_Node_Str"));
  }
  Assert.assertFalse(notDelete.isEmpty());
  for (  Location location : toDelete) {
    fileMetaDataManager.writeMetaData(dummyContext,deletionBoundary - RANDOM.nextInt(50000) - 10000,createFile(location));
  }
  for (  Location location : notDelete) {
    fileMetaDataManager.writeMetaData(dummyContext,deletionBoundary + RANDOM.nextInt(50000) + 10000,createFile(location));
  }
  Assert.assertEquals(locationListsToString(toDelete,notDelete),toDelete.size() + notDelete.size(),fileMetaDataManager.listFiles(dummyContext).size());
  LogCleanup logCleanup=new LogCleanup(fileMetaDataManager,baseDir,RETENTION_DURATION_MS);
  logCleanup.run();
  logCleanup.run();
  for (  Location location : toDelete) {
    Assert.assertFalse("String_Node_Str" + location.toURI() + "String_Node_Str",location.exists());
  }
  for (  Location location : notDelete) {
    Assert.assertTrue("String_Node_Str" + location.toURI() + "String_Node_Str",location.exists());
  }
  for (int i=0; i < 5; ++i) {
    Location delDir=contextDir.append("String_Node_Str" + i);
    Assert.assertFalse("String_Node_Str" + delDir.toURI() + "String_Node_Str",delDir.exists());
  }
}