Program: 24687
Project: 24687
Buggy source:
/** 
 * Does the work of turning DocHits into XML.
 * @param docHits Array of DocHits to structure
 * @param buf     Buffer to add the XML to
 */
private void structureDocHits(DocHit[] docHits,int startDoc,StringBuffer buf){
  if (docHits == null)   return;
  for (int i=0; i < docHits.length; i++) {
    DocHit docHit=docHits[i];
    String scoreStr;
    if (scoresNormalized)     scoreStr=Integer.toString(Math.round(docHit.score * 100));
 else {
      if (decFormat == null)       decFormat=(DecimalFormat)DecimalFormat.getInstance();
      scoreStr=decFormat.format(docHit.score);
    }
    buf.append("String_Node_Str" + "String_Node_Str" + (i + startDoc + 1) + "String_Node_Str"+ "String_Node_Str"+ TextServlet.makeHtmlString(docHit.filePath())+ "String_Node_Str"+ "String_Node_Str"+ scoreStr+ "String_Node_Str"+ "String_Node_Str"+ docHit.totalSnippets()+ "String_Node_Str");
    if (docHit.recordNum() > 0)     buf.append("String_Node_Str" + docHit.recordNum() + "String_Node_Str");
    if (docHit.subDocument() != null)     buf.append("String_Node_Str" + docHit.subDocument() + "String_Node_Str");
    buf.append("String_Node_Str");
    Explanation explanation=docHit.explanation();
    if (explanation != null)     structureExplanation(explanation,buf);
    if (!docHit.metaData().isEmpty()) {
      buf.append("String_Node_Str");
      for (Iterator atts=docHit.metaData().iterator(); atts.hasNext(); ) {
        Attrib attrib=(Attrib)atts.next();
        buf.append(attrib.value);
      }
      buf.append("String_Node_Str");
    }
    for (int j=0; j < docHit.nSnippets(); j++) {
      Snippet snippet=docHit.snippet(j,true);
      buf.append("String_Node_Str" + (j + 1) + "String_Node_Str"+ Math.round(snippet.score * 100)+ "String_Node_Str");
      if (snippet.sectionType != null)       buf.append("String_Node_Str" + snippet.sectionType + "String_Node_Str");
      buf.append("String_Node_Str" + TextServlet.makeHtmlString(snippet.text,true) + "String_Node_Str");
    }
    buf.append("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Does the work of turning DocHits into XML.
 * @param docHits Array of DocHits to structure
 * @param buf     Buffer to add the XML to
 */
private void structureDocHits(DocHit[] docHits,int startDoc,StringBuffer buf){
  if (docHits == null)   return;
  for (int i=0; i < docHits.length; i++) {
    DocHit docHit=docHits[i];
    String scoreStr;
    if (scoresNormalized)     scoreStr=Integer.toString(Math.round(docHit.score * 100));
 else {
      if (decFormat == null)       decFormat=(DecimalFormat)DecimalFormat.getInstance();
      scoreStr=decFormat.format(docHit.score);
    }
    buf.append("String_Node_Str" + "String_Node_Str" + (i + startDoc + 1) + "String_Node_Str"+ "String_Node_Str"+ TextServlet.makeHtmlString(docHit.filePath())+ "String_Node_Str"+ "String_Node_Str"+ scoreStr+ "String_Node_Str"+ "String_Node_Str"+ docHit.totalSnippets()+ "String_Node_Str");
    if (docHit.recordNum() > 0)     buf.append("String_Node_Str" + docHit.recordNum() + "String_Node_Str");
    if (docHit.subDocument() != null)     buf.append("String_Node_Str" + TextServlet.makeHtmlString(docHit.subDocument()) + "String_Node_Str");
    buf.append("String_Node_Str");
    Explanation explanation=docHit.explanation();
    if (explanation != null)     structureExplanation(explanation,buf);
    if (!docHit.metaData().isEmpty()) {
      buf.append("String_Node_Str");
      for (Iterator atts=docHit.metaData().iterator(); atts.hasNext(); ) {
        Attrib attrib=(Attrib)atts.next();
        buf.append(attrib.value);
      }
      buf.append("String_Node_Str");
    }
    for (int j=0; j < docHit.nSnippets(); j++) {
      Snippet snippet=docHit.snippet(j,true);
      buf.append("String_Node_Str" + (j + 1) + "String_Node_Str"+ Math.round(snippet.score * 100)+ "String_Node_Str");
      if (snippet.sectionType != null)       buf.append("String_Node_Str" + snippet.sectionType + "String_Node_Str");
      buf.append("String_Node_Str" + TextServlet.makeHtmlString(snippet.text,true) + "String_Node_Str");
    }
    buf.append("String_Node_Str");
  }
}