Program: 24842
Project: 24842
Buggy source:
/** 
 * Open a TextIndexer (Lucene) index for reading or writing. <br><br> The primary purpose of this method is to open the index identified by the  <code>cfgInfo</code> for reading and searching. Index reading and searching operations are used to clean, cull, or optimize an index. Opening an index for writing is performed by the method   {@link XMLTextProcessor#openIdxForWriting() openIdxForWriting()}only when the index is being updated with new document information. <br><br> 
 * @param homePath Path from which to resolve relative path names.<br>
 * @param idxInfo  A config structure containing information about the indexto open. <br>
 * @param clean    true to truncate any existing index; false to add to it.<br><br>
 * @.notes This method will create an index if it doesn't exist, or truncate an index that does exist if the <code>clean</code> flag is set in the  <code>cfgInfo</code> structure. <br><br> This method makes a private internal reference  {@link XMLTextProcessor#configInfo configInfo}to the passed configuration structure for use by other methods in this  class. <br><br>
 * @throws IOException  Any I/O exceptions that occurred during the opening,creation, or truncation of the Lucene index. <br><br>
 */
public void open(String homePath,IndexInfo idxInfo,boolean clean) throws IOException {
  fileQueue=new LinkedList();
  try {
    this.indexInfo=idxInfo;
    this.xtfHomePath=homePath;
    indexPath=getIndexPath();
    if (indexInfo.stopWords != null)     stopSet=NgramStopFilter.makeStopSet(indexInfo.stopWords);
    if (clean) {
      Path.createPath(indexPath);
      createIndex(indexPath);
    }
 else {
      Path.createPath(indexPath);
      FSDirectory idxDir=FSDirectory.getDirectory(indexPath,false);
      if (!IndexReader.indexExists(idxDir))       createIndex(indexPath);
    }
    indexReader=IndexReader.open(indexPath);
    indexSearcher=new IndexSearcher(indexReader);
    Hits match=indexSearcher.search(new TermQuery(new Term("String_Node_Str","String_Node_Str")));
    if (match.length() == 0)     throw new RuntimeException("String_Node_Str");
    Document doc=match.doc(0);
    if (Integer.parseInt(doc.get("String_Node_Str")) != indexInfo.getChunkSize()) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.getChunkSize()+ "String_Node_Str");
    }
    if (Integer.parseInt(doc.get("String_Node_Str")) != indexInfo.getChunkOvlp()) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.getChunkOvlp()+ "String_Node_Str");
    }
    String stopWords=indexInfo.stopWords;
    if (stopWords == null)     stopWords="String_Node_Str";
    if (!doc.get("String_Node_Str").equals(stopWords)) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.stopWords+ "String_Node_Str");
    }
  }
 catch (  IOException e) {
    Trace.tab();
    Trace.error("String_Node_Str" + e);
    Trace.untab();
    close();
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Open a TextIndexer (Lucene) index for reading or writing. <br><br> The primary purpose of this method is to open the index identified by the  <code>cfgInfo</code> for reading and searching. Index reading and searching operations are used to clean, cull, or optimize an index. Opening an index for writing is performed by the method   {@link XMLTextProcessor#openIdxForWriting() openIdxForWriting()}only when the index is being updated with new document information. <br><br> 
 * @param homePath Path from which to resolve relative path names.<br>
 * @param idxInfo  A config structure containing information about the indexto open. <br>
 * @param clean    true to truncate any existing index; false to add to it.<br><br>
 * @.notes This method will create an index if it doesn't exist, or truncate an index that does exist if the <code>clean</code> flag is set in the  <code>cfgInfo</code> structure. <br><br> This method makes a private internal reference  {@link XMLTextProcessor#configInfo configInfo}to the passed configuration structure for use by other methods in this  class. <br><br>
 * @throws IOException  Any I/O exceptions that occurred during the opening,creation, or truncation of the Lucene index. <br><br>
 */
public void open(String homePath,IndexInfo idxInfo,boolean clean) throws IOException {
  fileQueue=new LinkedList();
  try {
    this.indexInfo=idxInfo;
    this.xtfHomePath=homePath;
    indexPath=getIndexPath();
    if (indexInfo.stopWords != null)     stopSet=NgramStopFilter.makeStopSet(indexInfo.stopWords);
    if (clean) {
      Path.createPath(indexPath);
      createIndex(indexPath);
    }
 else {
      Path.createPath(indexPath);
      FSDirectory idxDir=FSDirectory.getDirectory(indexPath,false);
      if (!IndexReader.indexExists(idxDir))       createIndex(indexPath);
    }
    openIdxForReading();
    Hits match=indexSearcher.search(new TermQuery(new Term("String_Node_Str","String_Node_Str")));
    if (match.length() == 0)     throw new RuntimeException("String_Node_Str");
    Document doc=match.doc(0);
    if (Integer.parseInt(doc.get("String_Node_Str")) != indexInfo.getChunkSize()) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.getChunkSize()+ "String_Node_Str");
    }
    if (Integer.parseInt(doc.get("String_Node_Str")) != indexInfo.getChunkOvlp()) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.getChunkOvlp()+ "String_Node_Str");
    }
    String stopWords=indexInfo.stopWords;
    if (stopWords == null)     stopWords="String_Node_Str";
    if (!doc.get("String_Node_Str").equals(stopWords)) {
      throw new RuntimeException("String_Node_Str" + doc.get("String_Node_Str") + "String_Node_Str"+ indexInfo.stopWords+ "String_Node_Str");
    }
  }
 catch (  IOException e) {
    Trace.tab();
    Trace.error("String_Node_Str" + e);
    Trace.untab();
    close();
    throw e;
  }
}