Program: 136477
Project: 136477
Buggy source:
/** 
 * regenerate all indexes recursively.
 * @param inputFolder
 * @param outputFolder
 * @throws java.io.IOException
 */
private int regenerate(File inputFolder,File outputFolder) throws IOException {
  FSDirectory inputDir=FSDirectory.open(inputFolder);
  CheckIndex check=new CheckIndex(inputDir);
  Status status=check.checkIndex();
  if (status.missingSegments) {
    for (    File f : inputFolder.listFiles()) {
      if (f.isDirectory()) {
        File out=new File(outputFolder.getAbsolutePath() + "String_Node_Str" + f.getName());
        out.mkdir();
        regenerate(f,out);
      }
    }
  }
 else {
    System.out.println("String_Node_Str" + inputFolder.getPath());
    FSDirectory outputDir=FSDirectory.open(outputFolder);
    analyzer=new StandardAnalyzer(CharArraySet.EMPTY_SET);
    IndexWriterConfig config=new IndexWriterConfig(Version.LATEST,analyzer);
    IndexWriter writer=new IndexWriter(outputDir,config);
    IndexReader reader=DirectoryReader.open(inputDir);
    Collection<String> fieldNames=new ArrayList<String>();
    int count=0;
    Bits liveDocs=MultiFields.getLiveDocs(reader);
    for (int i=0; i < reader.maxDoc(); i++) {
      if (liveDocs != null && !liveDocs.get(i)) {
        continue;
      }
      Document doc=reader.document(i);
      List<IndexableField> fields=doc.getFields();
      for (int k=0; k < fields.size(); k++) {
        fieldNames.add(fields.get(k).name());
      }
      if (fieldNames.contains(F_WORD) && fieldNames.contains(F_SYN)) {
        String word=doc.getValues(F_WORD)[0];
        String[] synonyms=doc.getValues(F_SYN);
        Set<String> synonymSet=new HashSet<String>();
        for (        String syn : synonyms) {
          if (!syn.equals(word)) {
            synonymSet.add(syn);
          }
        }
        Document newDoc=generateDocument(word,synonymSet);
        writer.addDocument(newDoc);
      }
 else {
        writer.addDocument(doc);
      }
      count++;
    }
    System.out.println("String_Node_Str" + count);
    reader.close();
    writer.commit();
    writer.close();
    outputDir.close();
    for (    File file : inputFolder.listFiles()) {
      if (file.isFile() && !isLuceneIndexFile(file)) {
        copyFile(file,outputFolder);
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * regenerate all indexes recursively.
 * @param inputFolder
 * @param outputFolder
 * @throws java.io.IOException
 */
private int regenerate(File inputFolder,File outputFolder) throws IOException {
  FSDirectory inputDir=FSDirectory.open(inputFolder);
  CheckIndex check=new CheckIndex(inputDir);
  Status status=check.checkIndex();
  if (status.missingSegments) {
    for (    File f : inputFolder.listFiles()) {
      if (f.isDirectory()) {
        File out=new File(outputFolder.getAbsolutePath() + "String_Node_Str" + f.getName());
        out.mkdir();
        regenerate(f,out);
      }
    }
  }
 else {
    System.out.println("String_Node_Str" + inputFolder.getPath());
    FSDirectory outputDir=FSDirectory.open(outputFolder);
    analyzer=new StandardAnalyzer(CharArraySet.EMPTY_SET);
    IndexWriterConfig config=new IndexWriterConfig(Version.LATEST,analyzer);
    IndexWriter writer=new IndexWriter(outputDir,config);
    IndexReader reader=DirectoryReader.open(inputDir);
    Collection<String> fieldNames=new ArrayList<String>();
    int count=0;
    Bits liveDocs=MultiFields.getLiveDocs(reader);
    for (int i=0; i < reader.maxDoc(); i++) {
      if (liveDocs != null && !liveDocs.get(i)) {
        continue;
      }
      Document doc=reader.document(i);
      List<IndexableField> fields=doc.getFields();
      for (int k=0; k < fields.size(); k++) {
        fieldNames.add(fields.get(k).name());
      }
      if (fieldNames.contains(F_WORD)) {
        String word=doc.getValues(F_WORD)[0];
        String[] synonyms=doc.getValues(F_SYN);
        Set<String> synonymSet=new HashSet<String>();
        for (        String syn : synonyms) {
          if (!syn.equals(word)) {
            synonymSet.add(syn);
          }
        }
        Document newDoc=generateDocument(word,synonymSet);
        writer.addDocument(newDoc);
      }
 else {
        writer.addDocument(doc);
      }
      count++;
    }
    System.out.println("String_Node_Str" + count);
    reader.close();
    writer.commit();
    writer.close();
    outputDir.close();
    for (    File file : inputFolder.listFiles()) {
      if (file.isFile() && !isLuceneIndexFile(file)) {
        copyFile(file,outputFolder);
      }
    }
  }
  return 0;
}