Program: 60329
Project: 60329
Buggy source:
public void cookLoopToPrinter(Writer out,Chunk context,boolean isBlock,int depth) throws IOException {
  if (data == null || !data.hasNext()) {
    if (emptySnippet == null) {
      if (isBlock) {
        out.append("String_Node_Str");
      }
 else {
        out.append("String_Node_Str");
      }
    }
 else {
      emptySnippet.render(out,context,depth);
    }
    return;
  }
  Snippet dividerSnippet=null;
  boolean createArrayTags=false;
  boolean counterTags=false;
  String counterTag=null;
  String firstRunTag=null;
  String lastRunTag=null;
  if (options != null) {
    if (options.containsKey("String_Node_Str")) {
      dividerSnippet=(Snippet)options.get("String_Node_Str");
    }
 else     if (options.containsKey("String_Node_Str")) {
      String dividerTemplate=(String)options.get("String_Node_Str");
      ContentSource templates=context.getTemplateSet();
      if (templates != null && templates.provides(dividerTemplate)) {
        dividerSnippet=templates.getSnippet(dividerTemplate);
      }
 else {
        dividerSnippet=Snippet.getSnippet(dividerTemplate);
      }
      options.put("String_Node_Str",dividerSnippet);
    }
    if (options.containsKey("String_Node_Str")) {
      createArrayTags=true;
    }
    if (options.containsKey("String_Node_Str")) {
      counterTags=true;
    }
    if (options.containsKey("String_Node_Str")) {
      counterTag=(String)options.get("String_Node_Str");
      counterTag=eatTagSymbol(counterTag);
    }
    if (options.containsKey("String_Node_Str")) {
      String tagNames=(String)options.get("String_Node_Str");
      if (tagNames.indexOf("String_Node_Str") > 0) {
        String[] userFirstLast=tagNames.split("String_Node_Str");
        firstRunTag=eatTagSymbol(userFirstLast[0]);
        lastRunTag=eatTagSymbol(userFirstLast[1]);
      }
      if (firstRunTag == null || firstRunTag.length() == 0) {
        firstRunTag=FIRST_MARKER;
      }
      if (lastRunTag == null || lastRunTag.length() == 0) {
        lastRunTag=LAST_MARKER;
      }
    }
  }
  ChunkFactory factory=context.getChunkFactory();
  if (rowX == null) {
    rowX=(factory == null) ? new Chunk() : factory.makeChunk();
    rowX.append(rowSnippet);
  }
  String prefix=null;
  if (options != null && options.containsKey("String_Node_Str")) {
    String name=(String)options.get("String_Node_Str");
    prefix=name;
  }
  String[] columnLabels=data.getColumnLabels();
  if (createArrayTags && columnLabels == null) {
    createArrayTags=false;
  }
  String[] prefixedLabels=null;
  String[] prefixedIndices=null;
  String[] anonIndices=null;
  if (prefix != null && columnLabels != null) {
    prefixedLabels=new String[columnLabels.length];
    for (int i=columnLabels.length - 1; i > -1; i--) {
      prefixedLabels[i]=prefix + "String_Node_Str" + columnLabels[i];
    }
    if (createArrayTags) {
      prefixedIndices=new String[columnLabels.length];
      for (int i=0; i < prefixedIndices.length; i++) {
        prefixedIndices[i]=prefix + "String_Node_Str" + i+ "String_Node_Str";
      }
    }
  }
  if (createArrayTags) {
    anonIndices=new String[columnLabels.length];
    for (int i=0; i < anonIndices.length; i++) {
      anonIndices[i]="String_Node_Str" + i + "String_Node_Str";
    }
  }
  int counter=0;
  while (data.hasNext()) {
    if (counterTags) {
      rowX.set("String_Node_Str",counter);
      rowX.set("String_Node_Str",counter + 1);
    }
    if (counterTag != null) {
      rowX.set(counterTag,counter);
    }
    if (dividerSnippet != null && counter > 0) {
      dividerSnippet.render(out,context,depth);
    }
    Map<String,Object> record=data.nextRecord();
    if (columnLabels != null) {
      for (int i=columnLabels.length - 1; i > -1; i--) {
        String field=columnLabels[i];
        Object value=record.get(field);
        String fieldName=prefix == null ? field : prefixedLabels[i];
        rowX.setOrDelete(fieldName,value);
        if (createArrayTags) {
          rowX.setOrDelete(anonIndices[i],value);
          if (prefix != null) {
            rowX.setOrDelete(prefixedIndices[i],value);
          }
        }
      }
    }
 else {
      for (      String key : record.keySet()) {
        Object value=record.get(key);
        String fieldName=prefix == null ? key : prefix + "String_Node_Str" + key;
        rowX.setOrDelete(fieldName,value);
      }
    }
    if (prefix != null && columnLabels != null) {
      if (columnLabels.length == 1 && columnLabels[0].equals(SimpleTable.ANON_ARRAY_LABEL)) {
        rowX.setOrDelete(prefix,record.get(SimpleTable.ANON_ARRAY_LABEL));
      }
    }
    if (firstRunTag != null) {
      if (counter == 0) {
        rowX.set(firstRunTag,"String_Node_Str");
        if (prefix != null)         rowX.set(prefix + "String_Node_Str" + firstRunTag,"String_Node_Str");
      }
 else       if (counter == 1) {
        rowX.unset(firstRunTag);
        if (prefix != null)         rowX.unset(prefix + "String_Node_Str" + firstRunTag);
      }
    }
    if (lastRunTag != null) {
      if (!data.hasNext()) {
        rowX.set(lastRunTag,"String_Node_Str");
        if (prefix != null)         rowX.set(prefix + "String_Node_Str" + lastRunTag,"String_Node_Str");
      }
    }
    rowX.render(out,context);
    counter++;
  }
  data.reset();
  rowX.resetTags();
}

Fixed version (ground truth):
public void cookLoopToPrinter(Writer out,Chunk context,boolean isBlock,int depth) throws IOException {
  if (data == null || !data.hasNext()) {
    if (emptySnippet == null) {
      if (isBlock) {
        out.append("String_Node_Str");
      }
 else {
        out.append("String_Node_Str");
      }
    }
 else {
      emptySnippet.render(out,context,depth);
    }
    return;
  }
  Snippet dividerSnippet=null;
  boolean createArrayTags=false;
  boolean counterTags=false;
  String counterTag=null;
  String firstRunTag=null;
  String lastRunTag=null;
  if (options != null) {
    if (options.containsKey("String_Node_Str")) {
      dividerSnippet=(Snippet)options.get("String_Node_Str");
    }
 else     if (options.containsKey("String_Node_Str")) {
      String dividerTemplate=(String)options.get("String_Node_Str");
      ContentSource templates=context.getTemplateSet();
      if (templates != null && templates.provides(dividerTemplate)) {
        dividerSnippet=templates.getSnippet(dividerTemplate);
      }
 else {
        dividerSnippet=Snippet.getSnippet(dividerTemplate);
      }
      options.put("String_Node_Str",dividerSnippet);
    }
    if (options.containsKey("String_Node_Str")) {
      createArrayTags=true;
    }
    if (options.containsKey("String_Node_Str")) {
      counterTags=true;
    }
    if (options.containsKey("String_Node_Str")) {
      counterTag=(String)options.get("String_Node_Str");
      counterTag=eatTagSymbol(counterTag);
    }
    if (options.containsKey("String_Node_Str")) {
      String tagNames=(String)options.get("String_Node_Str");
      if (tagNames.indexOf("String_Node_Str") > 0) {
        String[] userFirstLast=tagNames.split("String_Node_Str");
        firstRunTag=eatTagSymbol(userFirstLast[0]);
        lastRunTag=eatTagSymbol(userFirstLast[1]);
      }
      if (firstRunTag == null || firstRunTag.length() == 0) {
        firstRunTag=FIRST_MARKER;
      }
      if (lastRunTag == null || lastRunTag.length() == 0) {
        lastRunTag=LAST_MARKER;
      }
    }
  }
  ChunkFactory factory=context.getChunkFactory();
  if (this.rowX == null) {
    this.rowX=(factory == null) ? new Chunk() : factory.makeChunk();
    this.rowX.append(rowSnippet);
  }
  if (context.getLocale() == null) {
    if (rowX.getLocale() != null)     rowX.setLocale(null);
  }
 else {
    if (rowX.getLocale() == null || rowX.getLocale() != context.getLocale()) {
      rowX.setLocale(context.getLocale().toString());
    }
  }
  String prefix=null;
  if (options != null && options.containsKey("String_Node_Str")) {
    String name=(String)options.get("String_Node_Str");
    prefix=name;
  }
  String[] columnLabels=data.getColumnLabels();
  if (createArrayTags && columnLabels == null) {
    createArrayTags=false;
  }
  String[] prefixedLabels=null;
  String[] prefixedIndices=null;
  String[] anonIndices=null;
  if (prefix != null && columnLabels != null) {
    prefixedLabels=new String[columnLabels.length];
    for (int i=columnLabels.length - 1; i > -1; i--) {
      prefixedLabels[i]=prefix + "String_Node_Str" + columnLabels[i];
    }
    if (createArrayTags) {
      prefixedIndices=new String[columnLabels.length];
      for (int i=0; i < prefixedIndices.length; i++) {
        prefixedIndices[i]=prefix + "String_Node_Str" + i+ "String_Node_Str";
      }
    }
  }
  if (createArrayTags) {
    anonIndices=new String[columnLabels.length];
    for (int i=0; i < anonIndices.length; i++) {
      anonIndices[i]="String_Node_Str" + i + "String_Node_Str";
    }
  }
  int counter=0;
  while (data.hasNext()) {
    if (counterTags) {
      rowX.set("String_Node_Str",counter);
      rowX.set("String_Node_Str",counter + 1);
    }
    if (counterTag != null) {
      rowX.set(counterTag,counter);
    }
    if (dividerSnippet != null && counter > 0) {
      dividerSnippet.render(out,context,depth);
    }
    Map<String,Object> record=data.nextRecord();
    if (columnLabels != null) {
      for (int i=columnLabels.length - 1; i > -1; i--) {
        String field=columnLabels[i];
        Object value=record.get(field);
        String fieldName=prefix == null ? field : prefixedLabels[i];
        rowX.setOrDelete(fieldName,value);
        if (createArrayTags) {
          rowX.setOrDelete(anonIndices[i],value);
          if (prefix != null) {
            rowX.setOrDelete(prefixedIndices[i],value);
          }
        }
      }
    }
 else {
      for (      String key : record.keySet()) {
        Object value=record.get(key);
        String fieldName=prefix == null ? key : prefix + "String_Node_Str" + key;
        rowX.setOrDelete(fieldName,value);
      }
    }
    if (prefix != null && columnLabels != null) {
      if (columnLabels.length == 1 && columnLabels[0].equals(SimpleTable.ANON_ARRAY_LABEL)) {
        rowX.setOrDelete(prefix,record.get(SimpleTable.ANON_ARRAY_LABEL));
      }
    }
    if (firstRunTag != null) {
      if (counter == 0) {
        rowX.set(firstRunTag,"String_Node_Str");
        if (prefix != null)         rowX.set(prefix + "String_Node_Str" + firstRunTag,"String_Node_Str");
      }
 else       if (counter == 1) {
        rowX.unset(firstRunTag);
        if (prefix != null)         rowX.unset(prefix + "String_Node_Str" + firstRunTag);
      }
    }
    if (lastRunTag != null) {
      if (!data.hasNext()) {
        rowX.set(lastRunTag,"String_Node_Str");
        if (prefix != null)         rowX.set(prefix + "String_Node_Str" + lastRunTag,"String_Node_Str");
      }
    }
    rowX.render(out,context);
    counter++;
  }
  data.reset();
  rowX.resetTags();
}