Program: 89615
Project: 89615
Buggy source:
/** 
 * Combine a number of crawl.log files into one Lucene index.  This index is placed as gzip files under the directory returned by getCacheFile().
 * @param rawfiles The map from job ID into crawl.log contents. Nonull values are allowed in this map.
 */
protected synchronized void combine(Map<Long,File> rawfiles){
  long datasetSize=rawfiles.values().size();
  log.info("String_Node_Str" + datasetSize + "String_Node_Str");
  File resultFile=getCacheFile(rawfiles.keySet());
  Set<File> tmpfiles=new HashSet<File>();
  String indexLocation=resultFile.getAbsolutePath() + "String_Node_Str";
  try {
    DigestIndexer indexer=createStandardIndexer(indexLocation);
    final boolean verboseIndexing=false;
    DigestOptions indexingOptions=new DigestOptions(this.useBlacklist,verboseIndexing,this.mimeFilter);
    long count=0;
    Set<IndexingState> outstandingJobs=new HashSet<IndexingState>();
    final int maxThreads=Settings.getInt(ArchiveSettings.INDEXSERVER_INDEXING_MAXTHREADS);
    ThreadPoolExecutor executor=new ThreadPoolExecutor(maxThreads,maxThreads,0L,TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    for (    Map.Entry<Long,File> entry : rawfiles.entrySet()) {
      Long jobId=entry.getKey();
      File crawlLog=entry.getValue();
      File tmpFile=new File(FileUtils.getTempDir(),UUID.randomUUID().toString());
      tmpfiles.add(tmpFile);
      String localindexLocation=tmpFile.getAbsolutePath();
      Long cached=cdxcache.cache(jobId);
      if (cached == null) {
        log.warn("String_Node_Str" + entry.getKey() + "String_Node_Str");
        continue;
      }
      File cachedCDXFile=cdxcache.getCacheFile(cached);
      count++;
      log.debug("String_Node_Str" + jobId + "String_Node_Str"+ count+ "String_Node_Str"+ datasetSize);
      Callable<Boolean> task=new DigestIndexerWorker(localindexLocation,jobId,crawlLog,cachedCDXFile,indexingOptions);
      Future<Boolean> result=executor.submit(task);
      outstandingJobs.add(new IndexingState(jobId,localindexLocation,result));
    }
    Set<Directory> subindices=new HashSet<Directory>();
    long combineTimeout=Settings.getLong(ArchiveSettings.INDEXSERVER_INDEXING_TIMEOUT);
    long timeOutTime=System.currentTimeMillis() + combineTimeout;
    while (outstandingJobs.size() > 0) {
      Iterator<IndexingState> iterator=outstandingJobs.iterator();
      if (timeOutTime < System.currentTimeMillis()) {
        log.warn("String_Node_Str" + combineTimeout + "String_Node_Str"+ "String_Node_Str"+ outstandingJobs+ "String_Node_Str");
        break;
      }
      while (iterator.hasNext()) {
        Future<Boolean> nextResult;
        IndexingState next=iterator.next();
        if (next.getResultObject().isDone()) {
          nextResult=next.getResultObject();
          try {
            if (nextResult.get()) {
              subindices.add(new SimpleFSDirectory(new File(next.getIndex())));
            }
 else {
              log.warn("String_Node_Str" + next.getJobIdentifier() + "String_Node_Str");
            }
          }
 catch (          InterruptedException e) {
            log.warn("String_Node_Str" + "String_Node_Str",e);
          }
catch (          ExecutionException e) {
            log.warn("String_Node_Str" + "String_Node_Str",e);
          }
          iterator.remove();
        }
      }
      sleepAwhile();
    }
    log.debug("String_Node_Str");
    indexer.getIndex().addIndexesNoOptimize(subindices.toArray(new Directory[0]));
    long docsInIndex=indexer.getIndex().numDocs();
    indexer.close(false);
    ZipUtils.gzipFiles(new File(indexLocation),resultFile);
    log.info("String_Node_Str" + datasetSize + "String_Node_Str"+ docsInIndex+ "String_Node_Str"+ FileUtils.getHumanReadableFileSize(resultFile));
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + resultFile.getAbsolutePath(),e);
  }
 finally {
    FileUtils.removeRecursively(new File(indexLocation));
    for (    File temporaryFile : tmpfiles) {
      FileUtils.removeRecursively(temporaryFile);
    }
  }
}

Fixed version (ground truth):
/** 
 * Combine a number of crawl.log files into one Lucene index.  This index is placed as gzip files under the directory returned by getCacheFile().
 * @param rawfiles The map from job ID into crawl.log contents. Nonull values are allowed in this map.
 */
protected synchronized void combine(Map<Long,File> rawfiles){
  long datasetSize=rawfiles.values().size();
  log.info("String_Node_Str" + datasetSize + "String_Node_Str");
  File resultDir=getCacheFile(rawfiles.keySet());
  Set<File> tmpfiles=new HashSet<File>();
  String indexLocation=resultDir.getAbsolutePath() + "String_Node_Str";
  try {
    DigestIndexer indexer=createStandardIndexer(indexLocation);
    final boolean verboseIndexing=false;
    DigestOptions indexingOptions=new DigestOptions(this.useBlacklist,verboseIndexing,this.mimeFilter);
    long count=0;
    Set<IndexingState> outstandingJobs=new HashSet<IndexingState>();
    final int maxThreads=Settings.getInt(ArchiveSettings.INDEXSERVER_INDEXING_MAXTHREADS);
    ThreadPoolExecutor executor=new ThreadPoolExecutor(maxThreads,maxThreads,0L,TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    for (    Map.Entry<Long,File> entry : rawfiles.entrySet()) {
      Long jobId=entry.getKey();
      File crawlLog=entry.getValue();
      File tmpFile=new File(FileUtils.getTempDir(),UUID.randomUUID().toString());
      tmpfiles.add(tmpFile);
      String localindexLocation=tmpFile.getAbsolutePath();
      Long cached=cdxcache.cache(jobId);
      if (cached == null) {
        log.warn("String_Node_Str" + entry.getKey() + "String_Node_Str");
        continue;
      }
      File cachedCDXFile=cdxcache.getCacheFile(cached);
      count++;
      log.debug("String_Node_Str" + jobId + "String_Node_Str"+ count+ "String_Node_Str"+ datasetSize);
      Callable<Boolean> task=new DigestIndexerWorker(localindexLocation,jobId,crawlLog,cachedCDXFile,indexingOptions);
      Future<Boolean> result=executor.submit(task);
      outstandingJobs.add(new IndexingState(jobId,localindexLocation,result));
    }
    Set<Directory> subindices=new HashSet<Directory>();
    long combineTimeout=Settings.getLong(ArchiveSettings.INDEXSERVER_INDEXING_TIMEOUT);
    long timeOutTime=System.currentTimeMillis() + combineTimeout;
    while (outstandingJobs.size() > 0) {
      Iterator<IndexingState> iterator=outstandingJobs.iterator();
      if (timeOutTime < System.currentTimeMillis()) {
        log.warn("String_Node_Str" + combineTimeout + "String_Node_Str"+ "String_Node_Str"+ outstandingJobs+ "String_Node_Str");
        break;
      }
      while (iterator.hasNext()) {
        Future<Boolean> nextResult;
        IndexingState next=iterator.next();
        if (next.getResultObject().isDone()) {
          nextResult=next.getResultObject();
          try {
            if (nextResult.get()) {
              subindices.add(new SimpleFSDirectory(new File(next.getIndex())));
            }
 else {
              log.warn("String_Node_Str" + next.getJobIdentifier() + "String_Node_Str");
            }
          }
 catch (          InterruptedException e) {
            log.warn("String_Node_Str" + "String_Node_Str",e);
          }
catch (          ExecutionException e) {
            log.warn("String_Node_Str" + "String_Node_Str",e);
          }
          iterator.remove();
        }
      }
      sleepAwhile();
    }
    log.debug("String_Node_Str");
    indexer.getIndex().addIndexesNoOptimize(subindices.toArray(new Directory[0]));
    long docsInIndex=indexer.getIndex().numDocs();
    indexer.close(false);
    ZipUtils.gzipFiles(new File(indexLocation),resultDir);
    log.info("String_Node_Str" + datasetSize + "String_Node_Str"+ docsInIndex+ "String_Node_Str"+ FileUtils.getHumanReadableFileSize(resultDir));
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + resultDir.getAbsolutePath(),e);
  }
 finally {
    FileUtils.removeRecursively(new File(indexLocation));
    for (    File temporaryFile : tmpfiles) {
      FileUtils.removeRecursively(temporaryFile);
    }
  }
}