Program: 61085
Project: 61085
Buggy source:
/** 
 * Compacts a partition of selected small mob files and all the del files in a batch.
 * @param request The compaction request.
 * @param partition A compaction partition.
 * @param connection To use for transport
 * @param table The current table.
 * @param filesToCompact The files to be compacted.
 * @param batch The number of mob files to be compacted in a batch.
 * @param bulkloadPathOfPartition The directory where the bulkload column of the currentpartition is saved.
 * @param bulkloadColumnPath The directory where the bulkload files of current partitionare saved.
 * @param newFiles The paths of new mob files after compactions.
 * @throws IOException if IO failure is encountered
 */
private void compactMobFilesInBatch(PartitionedMobCompactionRequest request,CompactionPartition partition,Connection connection,Table table,List<StoreFile> filesToCompact,int batch,Path bulkloadPathOfPartition,Path bulkloadColumnPath,List<Path> newFiles) throws IOException {
  StoreScanner scanner=createScanner(filesToCompact,ScanType.COMPACT_DROP_DELETES);
  List<StoreFile> mobFilesToCompact=filesToCompact.subList(0,batch);
  Pair<Long,Long> fileInfo=getFileInfo(mobFilesToCompact);
  StoreFileWriter writer=null;
  StoreFileWriter refFileWriter=null;
  Path filePath=null;
  long mobCells=0;
  boolean cleanupTmpMobFile=false;
  boolean cleanupBulkloadDirOfPartition=false;
  boolean cleanupCommittedMobFile=false;
  boolean closeReaders=true;
  try {
    try {
      writer=MobUtils.createWriter(conf,fs,column,partition.getPartitionId().getDate(),tempPath,Long.MAX_VALUE,column.getCompactionCompressionType(),partition.getPartitionId().getStartKey(),compactionCacheConfig,cryptoContext);
      cleanupTmpMobFile=true;
      filePath=writer.getPath();
      byte[] fileName=Bytes.toBytes(filePath.getName());
      refFileWriter=MobUtils.createRefFileWriter(conf,fs,column,bulkloadColumnPath,fileInfo.getSecond().longValue(),compactionCacheConfig,cryptoContext);
      cleanupBulkloadDirOfPartition=true;
      List<Cell> cells=new ArrayList<>();
      boolean hasMore;
      ScannerContext scannerContext=ScannerContext.newBuilder().setBatchLimit(compactionKVMax).build();
      do {
        hasMore=scanner.next(cells,scannerContext);
        for (        Cell cell : cells) {
          writer.append(cell);
          KeyValue reference=MobUtils.createMobRefKeyValue(cell,fileName,tableNameTag);
          refFileWriter.append(reference);
          mobCells++;
        }
        cells.clear();
      }
 while (hasMore);
    }
  finally {
      scanner.close();
      if (cleanupTmpMobFile) {
        closeMobFileWriter(writer,fileInfo.getFirst(),mobCells);
      }
      if (cleanupBulkloadDirOfPartition) {
        closeRefFileWriter(refFileWriter,fileInfo.getFirst(),request.selectionTime);
      }
    }
    if (mobCells > 0) {
      MobUtils.commitFile(conf,fs,filePath,mobFamilyDir,compactionCacheConfig);
      cleanupTmpMobFile=false;
      cleanupCommittedMobFile=true;
      bulkloadRefFile(connection,table,bulkloadPathOfPartition,filePath.getName());
      cleanupCommittedMobFile=false;
      newFiles.add(new Path(mobFamilyDir,filePath.getName()));
    }
    try {
      closeStoreFileReaders(mobFilesToCompact);
      closeReaders=false;
      MobUtils.removeMobFiles(conf,fs,tableName,mobTableDir,column.getName(),mobFilesToCompact);
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str" + mobFilesToCompact,e);
    }
  }
  finally {
    if (closeReaders) {
      closeStoreFileReaders(mobFilesToCompact);
    }
    if (cleanupTmpMobFile) {
      deletePath(filePath);
    }
    if (cleanupBulkloadDirOfPartition) {
      deletePath(bulkloadPathOfPartition);
    }
    if (cleanupCommittedMobFile) {
      deletePath(new Path(mobFamilyDir,filePath.getName()));
    }
  }
}

Fixed version (ground truth):
/** 
 * Compacts a partition of selected small mob files and all the del files in a batch.
 * @param request The compaction request.
 * @param partition A compaction partition.
 * @param connection To use for transport
 * @param table The current table.
 * @param filesToCompact The files to be compacted.
 * @param batch The number of mob files to be compacted in a batch.
 * @param bulkloadPathOfPartition The directory where the bulkload column of the currentpartition is saved.
 * @param bulkloadColumnPath The directory where the bulkload files of current partitionare saved.
 * @param newFiles The paths of new mob files after compactions.
 * @throws IOException if IO failure is encountered
 */
private void compactMobFilesInBatch(PartitionedMobCompactionRequest request,CompactionPartition partition,Connection connection,Table table,List<StoreFile> filesToCompact,int batch,Path bulkloadPathOfPartition,Path bulkloadColumnPath,List<Path> newFiles) throws IOException {
  StoreScanner scanner=createScanner(filesToCompact,ScanType.COMPACT_DROP_DELETES);
  List<StoreFile> mobFilesToCompact=filesToCompact.subList(0,batch);
  Pair<Long,Long> fileInfo=getFileInfo(mobFilesToCompact);
  StoreFileWriter writer=null;
  StoreFileWriter refFileWriter=null;
  Path filePath=null;
  Path refFilePath=null;
  long mobCells=0;
  try {
    writer=MobUtils.createWriter(conf,fs,column,partition.getPartitionId().getDate(),tempPath,Long.MAX_VALUE,column.getCompactionCompressionType(),partition.getPartitionId().getStartKey(),compactionCacheConfig,cryptoContext);
    filePath=writer.getPath();
    byte[] fileName=Bytes.toBytes(filePath.getName());
    refFileWriter=MobUtils.createRefFileWriter(conf,fs,column,bulkloadColumnPath,fileInfo.getSecond().longValue(),compactionCacheConfig,cryptoContext);
    refFilePath=refFileWriter.getPath();
    List<Cell> cells=new ArrayList<>();
    boolean hasMore;
    ScannerContext scannerContext=ScannerContext.newBuilder().setBatchLimit(compactionKVMax).build();
    do {
      hasMore=scanner.next(cells,scannerContext);
      for (      Cell cell : cells) {
        writer.append(cell);
        KeyValue reference=MobUtils.createMobRefKeyValue(cell,fileName,tableNameTag);
        refFileWriter.append(reference);
        mobCells++;
      }
      cells.clear();
    }
 while (hasMore);
  }
  finally {
    scanner.close();
    closeMobFileWriter(writer,fileInfo.getFirst(),mobCells);
    closeRefFileWriter(refFileWriter,fileInfo.getFirst(),request.selectionTime);
  }
  if (mobCells > 0) {
    MobUtils.commitFile(conf,fs,filePath,mobFamilyDir,compactionCacheConfig);
    bulkloadRefFile(connection,table,bulkloadPathOfPartition,filePath.getName());
    newFiles.add(new Path(mobFamilyDir,filePath.getName()));
  }
 else {
    deletePath(filePath);
    deletePath(refFilePath);
  }
  try {
    closeStoreFileReaders(mobFilesToCompact);
    MobUtils.removeMobFiles(conf,fs,tableName,mobTableDir,column.getName(),mobFilesToCompact);
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str" + mobFilesToCompact,e);
  }
}