Program: 16174
Project: 16174
Buggy source:
public void redraw(Writer out) throws java.io.IOException {
  final Execution exec=Executions.getCurrent();
  final boolean root=getParent() == null && (getPage().isComplete() || (exec != null && "String_Node_Str".equals(ExecutionsCtrl.getPageRedrawControl(exec))));
  if (exec == null || exec.isAsyncUpdate(null) || (!root && !HtmlPageRenders.isDirectContent(exec))) {
    super.redraw(out);
    return;
  }
  Writer oldout=null;
  if (exec != null && !HtmlPageRenders.isZkTagsGenerated(exec) && exec.getAttribute(ATTR_TOP_NATIVE) == null) {
    String tn;
    if (root || "String_Node_Str".equals(tn=_tag != null ? _tag.toLowerCase() : "String_Node_Str") || "String_Node_Str".equals(tn)|| "String_Node_Str".equals(tn)) {
      exec.setAttribute(ATTR_TOP_NATIVE,Boolean.TRUE);
      oldout=out;
      out=new StringWriter();
    }
  }
  out.write(getPrologHalf());
  Component child=getFirstChild();
  if (child == null) {
    if (root)     HtmlPageRenders.outStandalone(exec,null,out);
  }
 else {
    if (root)     HtmlPageRenders.setDirectContent(exec,true);
    do {
      Component next=child.getNextSibling();
      if (child instanceof Native || ((ComponentCtrl)child).getExtraCtrl() instanceof DirectContent) {
        ((ComponentCtrl)child).redraw(out);
      }
 else {
        HtmlPageRenders.setDirectContent(exec,false);
        HtmlPageRenders.outStandalone(exec,child,out);
        HtmlPageRenders.setDirectContent(exec,true);
      }
      child=next;
    }
 while (child != null);
  }
  out.write(getEpilogHalf());
  if (oldout != null) {
    exec.removeAttribute(ATTR_TOP_NATIVE);
    final StringBuffer sb=((StringWriter)out).getBuffer();
    if (!HtmlPageRenders.isZkTagsGenerated(exec)) {
      int jhead=-1, junav=-1, head=-1, heade=-1, html=-1;
      boolean unavailDone=false;
      for (int j=0, len=sb.length(); (j=sb.indexOf("String_Node_Str",j)) >= 0; ) {
        ++j;
        if (jhead < 0 && startsWith(sb,"String_Node_Str",j)) {
          int l=Strings.indexOf(sb,'>',j) + 1;
          sb.delete(jhead=--j,l);
          len=sb.length();
        }
 else         if (head < 0 && startsWith(sb,"String_Node_Str",j)) {
          head=Strings.indexOf(sb,'>',j) + 1;
        }
 else         if (html < 0 && startsWith(sb,"String_Node_Str",j)) {
          html=Strings.indexOf(sb,'>',j) + 1;
        }
 else         if (junav < 0 && startsWith(sb,"String_Node_Str",j)) {
          junav=Strings.indexOf(sb,'>',j) + 1;
          break;
        }
 else         if (sb.charAt(j) == '/' && startsWith(sb,"String_Node_Str",++j)) {
          heade=j - 2;
        }
      }
      boolean disableUnavailable=false;
      if (jhead < 0 && ((jhead=heade) < 0) && ((jhead=head) < 0) && ((jhead=junav) < 0) && ((jhead=html) < 0)) {
        if (_tag != null) {
          final String tn=_tag.toLowerCase();
          if ("String_Node_Str".equals(tn) || "String_Node_Str".equals(tn)) {
            l_loop:             for (int j=0, len=sb.length(); j < len; ++j) switch (sb.charAt(j)) {
case '>':
              disableUnavailable=true;
            jhead=j + 1;
case '=':
case '"':
          break l_loop;
      }
    }
  }
  if (jhead < 0)   jhead=0;
}
final String msg=HtmlPageRenders.outUnavailable(exec);
if (msg != null && !disableUnavailable) {
  if (junav < 0) {
    if (html >= 0)     junav=sb.lastIndexOf("String_Node_Str");
  }
  if (junav >= 0)   sb.insert(junav < jhead ? jhead : junav,msg);
 else   sb.append(msg);
}
final String zktags=HtmlPageRenders.outHeaderZkTags(exec,getPage());
if (zktags != null) sb.insert(jhead,zktags);
}
oldout.write(sb.toString());
}
}

Fixed version (ground truth):
public void redraw(Writer out) throws java.io.IOException {
  final Execution exec=Executions.getCurrent();
  final boolean root=getParent() == null && (getPage().isComplete() || (exec != null && "String_Node_Str".equals(ExecutionsCtrl.getPageRedrawControl(exec))));
  if (exec == null || exec.isAsyncUpdate(null) || (!root && !HtmlPageRenders.isDirectContent(exec))) {
    super.redraw(out);
    return;
  }
  Writer oldout=null;
  if (exec != null && !HtmlPageRenders.isZkTagsGenerated(exec) && exec.getAttribute(ATTR_TOP_NATIVE) == null) {
    String tn;
    if (root || "String_Node_Str".equals(tn=_tag != null ? _tag.toLowerCase() : "String_Node_Str") || "String_Node_Str".equals(tn)|| "String_Node_Str".equals(tn)) {
      exec.setAttribute(ATTR_TOP_NATIVE,Boolean.TRUE);
      oldout=out;
      out=new StringWriter();
    }
  }
  out.write(getPrologHalf());
  Component child=getFirstChild();
  if (child == null) {
    if (root)     HtmlPageRenders.outStandalone(exec,null,out);
  }
 else {
    if (root)     HtmlPageRenders.setDirectContent(exec,true);
    do {
      Component next=child.getNextSibling();
      if (child instanceof Native || ((ComponentCtrl)child).getExtraCtrl() instanceof DirectContent) {
        ((ComponentCtrl)child).redraw(out);
      }
 else {
        HtmlPageRenders.setDirectContent(exec,false);
        HtmlPageRenders.outStandalone(exec,child,out);
        HtmlPageRenders.setDirectContent(exec,true);
      }
      child=next;
    }
 while (child != null);
  }
  out.write(getEpilogHalf());
  if (oldout != null) {
    exec.removeAttribute(ATTR_TOP_NATIVE);
    final StringBuffer sb=((StringWriter)out).getBuffer();
    if (!HtmlPageRenders.isZkTagsGenerated(exec)) {
      int jhead=-1, junav=-1, head=-1, heade=-1, html=-1;
      for (int j=0, len=sb.length(); (j=sb.indexOf("String_Node_Str",j)) >= 0; ) {
        ++j;
        if (jhead < 0 && startsWith(sb,"String_Node_Str",j)) {
          int l=Strings.indexOf(sb,'>',j) + 1;
          sb.delete(jhead=--j,l);
          len=sb.length();
        }
 else         if (head < 0 && startsWith(sb,"String_Node_Str",j)) {
          head=Strings.indexOf(sb,'>',j) + 1;
        }
 else         if (html < 0 && startsWith(sb,"String_Node_Str",j)) {
          html=Strings.indexOf(sb,'>',j) + 1;
        }
 else         if (junav < 0 && startsWith(sb,"String_Node_Str",j)) {
          junav=Strings.indexOf(sb,'>',j) + 1;
          break;
        }
 else         if (sb.charAt(j) == '/' && startsWith(sb,"String_Node_Str",++j)) {
          heade=j - 2;
        }
      }
      boolean disableUnavailable=false;
      if (jhead < 0 && ((jhead=heade) < 0) && ((jhead=head) < 0) && ((jhead=junav) < 0) && ((jhead=html) < 0)) {
        if (_tag != null) {
          final String tn=_tag.toLowerCase();
          if ("String_Node_Str".equals(tn) || "String_Node_Str".equals(tn)) {
            l_loop:             for (int j=0, len=sb.length(); j < len; ++j) switch (sb.charAt(j)) {
case '>':
              disableUnavailable=true;
            jhead=j + 1;
case '=':
case '"':
          break l_loop;
      }
    }
  }
  if (jhead < 0)   jhead=0;
}
final String msg=HtmlPageRenders.outUnavailable(exec);
if (msg != null && !disableUnavailable) {
  if (junav < 0) {
    if (html >= 0)     junav=sb.lastIndexOf("String_Node_Str");
  }
  if (junav >= 0)   sb.insert(junav < jhead ? jhead : junav,msg);
 else   sb.append(msg);
}
final String zktags=HtmlPageRenders.outHeaderZkTags(exec,getPage());
if (zktags != null) sb.insert(jhead,zktags);
}
oldout.write(sb.toString());
}
}