Program: 15932
Project: 15932
Buggy source:
/** 
 * Returns the HTML content representing a page.
 * @param au whether it is caused by asynchronous update
 * @param exec the execution (never null)
 */
public static final void outPageContent(Execution exec,Page page,Writer out,boolean au) throws IOException {
  final Desktop desktop=page.getDesktop();
  final PageCtrl pageCtrl=(PageCtrl)page;
  final Component owner=pageCtrl.getOwner();
  boolean contained=owner == null && exec.isIncluded();
  String style=page.getStyle();
  if (style == null || style.length() == 0) {
    style=null;
    String wd=null, hgh=null;
    if (owner instanceof HtmlBasedComponent) {
      final HtmlBasedComponent hbc=(HtmlBasedComponent)owner;
      wd=hbc.getWidth();
      hgh=hbc.getHeight();
    }
    if (wd != null || hgh != null || contained) {
      final StringBuffer sb=new StringBuffer(32);
      HTMLs.appendStyle(sb,"String_Node_Str",wd != null ? wd : "String_Node_Str");
      HTMLs.appendStyle(sb,"String_Node_Str",hgh != null ? hgh : contained ? null : "String_Node_Str");
      style=sb.toString();
    }
  }
  RenderContext rc=null, old=null;
  final boolean aupg=exec.isAsyncUpdate(page);
  final boolean includedAndPart=owner != null && !aupg;
  final boolean divRequired=!au || includedAndPart;
  final boolean standalone=!au && owner == null;
  if (standalone) {
    rc=new RenderContext(out,new StringWriter(),desktop.getWebApp().getConfiguration().isCrawlable(),false);
    setRenderContext(exec,rc);
  }
 else   if (owner != null) {
    old=getRenderContext(exec);
    final boolean crawlable=old != null && old.temp != null && desktop.getWebApp().getConfiguration().isCrawlable();
    setRenderContext(exec,crawlable ? new RenderContext(old.temp,null,true,true) : null);
  }
  if (divRequired) {
    outDivTemplateBegin(out,page.getUuid());
  }
  if (standalone) {
    out=new StringWriter();
  }
 else   if (divRequired) {
    outDivTemplateEnd(page,out);
  }
  if (includedAndPart) {
    out=new StringWriter();
  }
 else   if (divRequired) {
    out.write("String_Node_Str");
  }
  exec.setAttribute(ATTR_DESKTOP_JS_GENED,Boolean.TRUE);
  final int order=ComponentRedraws.beforeRedraw(false);
  final String extra;
  try {
    if (order < 0) {
      if (aupg)       out.write('[');
 else {
        out.write(outSpecialJS(desktop));
        out.write(divRequired ? "String_Node_Str" : "String_Node_Str");
      }
    }
 else     if (order > 0)     out.write(',');
    out.write("String_Node_Str");
    out.write(page.getUuid());
    out.write("String_Node_Str");
    final StringBuffer props=new StringBuffer(128);
    final String pgid=page.getId();
    if (pgid.length() > 0)     appendProp(props,"String_Node_Str",pgid);
    if (owner != null) {
      appendProp(props,"String_Node_Str",owner.getUuid());
    }
 else {
      appendProp(props,"String_Node_Str",desktop.getId());
      appendProp(props,"String_Node_Str",getContextURI(exec));
      appendProp(props,"String_Node_Str",desktop.getUpdateURI(null));
      appendProp(props,"String_Node_Str",desktop.getRequestPath());
    }
    final String pageWgtCls=pageCtrl.getWidgetClass();
    if (pageWgtCls != null)     appendProp(props,"String_Node_Str",pageWgtCls);
    if (style != null)     appendProp(props,"String_Node_Str",style);
    if (!isClientROD(page))     appendProp(props,"String_Node_Str",Boolean.FALSE);
    if (contained)     appendProp(props,"String_Node_Str",Boolean.TRUE);
    out.write(props.toString());
    out.write("String_Node_Str");
    out.write("String_Node_Str");
    for (Component root=page.getFirstRoot(); root != null; root=root.getNextSibling())     ((ComponentCtrl)root).redraw(out);
    out.write("String_Node_Str");
  }
  finally {
    extra=ComponentRedraws.afterRedraw();
  }
  if (order < 0) {
    outEndJavaScriptFunc(exec,out,extra,aupg);
  }
  if (standalone) {
    setRenderContext(exec,null);
    StringBuffer sw=((StringWriter)out).getBuffer();
    out=rc.temp;
    if (divRequired)     outDivTemplateEnd(page,out);
    Files.write(out,((StringWriter)rc.perm).getBuffer());
    Files.write(out,new StringBuffer(sw.toString().replaceAll("String_Node_Str","String_Node_Str")));
  }
 else   if (owner != null) {
    setRenderContext(exec,old);
  }
  if (includedAndPart) {
    ((Includer)owner).setRenderingResult(((StringWriter)out).toString());
  }
 else   if (divRequired) {
    out.write("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Returns the HTML content representing a page.
 * @param au whether it is caused by asynchronous update
 * @param exec the execution (never null)
 */
public static final void outPageContent(Execution exec,Page page,Writer out,boolean au) throws IOException {
  final Desktop desktop=page.getDesktop();
  final PageCtrl pageCtrl=(PageCtrl)page;
  final Component owner=pageCtrl.getOwner();
  boolean contained=owner == null && exec.isIncluded();
  String style=page.getStyle();
  if (style == null || style.length() == 0) {
    style=null;
    String wd=null, hgh=null;
    if (owner instanceof HtmlBasedComponent) {
      final HtmlBasedComponent hbc=(HtmlBasedComponent)owner;
      wd=hbc.getWidth();
      hgh=hbc.getHeight();
    }
    if (wd != null || hgh != null || contained) {
      final StringBuffer sb=new StringBuffer(32);
      HTMLs.appendStyle(sb,"String_Node_Str",wd != null ? wd : "String_Node_Str");
      HTMLs.appendStyle(sb,"String_Node_Str",hgh != null ? hgh : contained ? null : "String_Node_Str");
      style=sb.toString();
    }
  }
  RenderContext rc=null, old=null;
  final boolean aupg=exec.isAsyncUpdate(page);
  final boolean includedAndPart=owner != null && !aupg;
  final boolean divRequired=!au || includedAndPart;
  final boolean standalone=!au && owner == null;
  if (standalone) {
    rc=new RenderContext(out,new StringWriter(),desktop.getWebApp().getConfiguration().isCrawlable(),false);
    setRenderContext(exec,rc);
  }
 else   if (owner != null) {
    old=getRenderContext(exec);
    final boolean crawlable=old != null && old.temp != null && desktop.getWebApp().getConfiguration().isCrawlable();
    setRenderContext(exec,crawlable ? new RenderContext(old.temp,null,true,true) : null);
  }
  if (divRequired) {
    outDivTemplateBegin(out,page.getUuid());
  }
  if (standalone) {
    out=new StringWriter();
  }
 else   if (divRequired) {
    outDivTemplateEnd(page,out);
  }
  if (includedAndPart) {
    out=new StringWriter();
  }
 else   if (divRequired) {
    out.write("String_Node_Str");
  }
  exec.setAttribute(ATTR_DESKTOP_JS_GENED,Boolean.TRUE);
  final int order=ComponentRedraws.beforeRedraw(false);
  final String extra;
  try {
    if (order < 0) {
      if (aupg)       out.write('[');
 else {
        out.write(outSpecialJS(desktop));
        WebApp webApp=WebApps.getCurrent();
        Configuration configuration=webApp.getConfiguration();
        Map<String,DataHandlerInfo> dataHandlers=configuration.getDataHandlers();
        for (        Map.Entry<String,DataHandlerInfo> me : dataHandlers.entrySet()) {
          DataHandlerInfo handler=me.getValue();
          String script=handler.getScript();
          String scriptUri=handler.getScriptUri();
          if (scriptUri != null) {
            script=Devices.loadJavaScript(exec,scriptUri);
          }
          out.write("String_Node_Str" + me.getKey() + "String_Node_Str"+ script+ "String_Node_Str");
        }
        out.write(divRequired ? "String_Node_Str" : "String_Node_Str");
      }
    }
 else     if (order > 0)     out.write(',');
    out.write("String_Node_Str");
    out.write(page.getUuid());
    out.write("String_Node_Str");
    final StringBuffer props=new StringBuffer(128);
    final String pgid=page.getId();
    if (pgid.length() > 0)     appendProp(props,"String_Node_Str",pgid);
    if (owner != null) {
      appendProp(props,"String_Node_Str",owner.getUuid());
    }
 else {
      appendProp(props,"String_Node_Str",desktop.getId());
      appendProp(props,"String_Node_Str",getContextURI(exec));
      appendProp(props,"String_Node_Str",desktop.getUpdateURI(null));
      appendProp(props,"String_Node_Str",desktop.getRequestPath());
    }
    final String pageWgtCls=pageCtrl.getWidgetClass();
    if (pageWgtCls != null)     appendProp(props,"String_Node_Str",pageWgtCls);
    if (style != null)     appendProp(props,"String_Node_Str",style);
    if (!isClientROD(page))     appendProp(props,"String_Node_Str",Boolean.FALSE);
    if (contained)     appendProp(props,"String_Node_Str",Boolean.TRUE);
    out.write(props.toString());
    out.write("String_Node_Str");
    out.write("String_Node_Str");
    for (Component root=page.getFirstRoot(); root != null; root=root.getNextSibling())     ((ComponentCtrl)root).redraw(out);
    out.write("String_Node_Str");
  }
  finally {
    extra=ComponentRedraws.afterRedraw();
  }
  if (order < 0) {
    outEndJavaScriptFunc(exec,out,extra,aupg);
  }
  if (standalone) {
    setRenderContext(exec,null);
    StringBuffer sw=((StringWriter)out).getBuffer();
    out=rc.temp;
    if (divRequired)     outDivTemplateEnd(page,out);
    Files.write(out,((StringWriter)rc.perm).getBuffer());
    Files.write(out,new StringBuffer(sw.toString().replaceAll("String_Node_Str","String_Node_Str")));
  }
 else   if (owner != null) {
    setRenderContext(exec,old);
  }
  if (includedAndPart) {
    ((Includer)owner).setRenderingResult(((StringWriter)out).toString());
  }
 else   if (divRequired) {
    out.write("String_Node_Str");
  }
}