Program: 35823
Project: 35823
Buggy source:
/** 
 * Retrieves a resource from the provider application and transforms it using the Renderer passed as a parameter. On of the Renderers that can be used is the AggregateRenderer that parses the html pages to find tags to be replaced by contents from other providers. Sample syntax used for includes : <ul> <li>&lt;!--$includeblock$provider$page$blockname$--&gt;</li> <li>&lt;!--$beginincludetemplate$provider$page$templatename$--&gt;</li> <li>&lt;!--$beginput$name$--&gt;</li> </ul> Sample syntax used inside included contents for template and block definition : <ul> <li>&lt;!--$beginblock$name$--&gt;</li> <li>&lt;!--$begintemplate$name$--&gt;</li> <li>&lt;!--$beginparam$name$--&gt;</li> </ul> Aggregation is always in "proxy mode" that means cookies or parameters from the original request are transmitted to the target server. <br/> <b>NB: Cookies and parameters are not transmitted to templates or blocks invoked by the page</b>.
 * @param relUrl the relative URL to the resource
 * @param request the request
 * @param response the response
 * @param propagateJsessionId indicates whether <code>jsessionid</code> should be propagated or just removed from generated output
 * @param renderer the renderer to use to transform the output or null if no transformation to apply
 * @throws IOException If an IOException occurs while writing to the response
 * @throws HttpErrorPage If the page contains incorrect tags
 */
public final void proxy(String relUrl,HttpServletRequest request,HttpServletResponse response,boolean propagateJsessionId,Renderer renderer) throws IOException, HttpErrorPage {
  RequestContext requestContext=new RequestContext(this,relUrl,null,request,propagateJsessionId,true);
  request.setCharacterEncoding(config.getUriEncoding());
  requestContext.setProxyMode(true);
  if (renderer == null) {
    renderResource(requestContext,new ResponseOutput(request,response));
  }
 else {
    TextOnlyStringOutput textOutput=new TextOnlyStringOutput(request,response);
    renderResource(requestContext,textOutput);
    if (!textOutput.hasTextBuffer()) {
      Driver.LOG.debug("String_Node_Str" + relUrl + "String_Node_Str");
      return;
    }
    Driver.LOG.debug("String_Node_Str" + relUrl + "String_Node_Str");
    renderer.render(textOutput.toString(),response.getWriter());
  }
}

Fixed version (ground truth):
/** 
 * Retrieves a resource from the provider application and transforms it using the Renderer passed as a parameter. On of the Renderers that can be used is the AggregateRenderer that parses the html pages to find tags to be replaced by contents from other providers. Sample syntax used for includes : <ul> <li>&lt;!--$includeblock$provider$page$blockname$--&gt;</li> <li>&lt;!--$beginincludetemplate$provider$page$templatename$--&gt;</li> <li>&lt;!--$beginput$name$--&gt;</li> </ul> Sample syntax used inside included contents for template and block definition : <ul> <li>&lt;!--$beginblock$name$--&gt;</li> <li>&lt;!--$begintemplate$name$--&gt;</li> <li>&lt;!--$beginparam$name$--&gt;</li> </ul> Aggregation is always in "proxy mode" that means cookies or parameters from the original request are transmitted to the target server. <br/> <b>NB: Cookies and parameters are not transmitted to templates or blocks invoked by the page</b>.
 * @param relUrl the relative URL to the resource
 * @param request the request
 * @param response the response
 * @param propagateJsessionId indicates whether <code>jsessionid</code> should be propagated or just removed from generated output
 * @param renderer the renderer to use to transform the output or null if no transformation to apply
 * @throws IOException If an IOException occurs while writing to the response
 * @throws HttpErrorPage If the page contains incorrect tags
 */
public final void proxy(String relUrl,HttpServletRequest request,HttpServletResponse response,boolean propagateJsessionId,Renderer renderer) throws IOException, HttpErrorPage {
  RequestContext requestContext=new RequestContext(this,relUrl,null,request,propagateJsessionId,true);
  request.setCharacterEncoding(config.getUriEncoding());
  requestContext.setProxyMode(true);
  if (renderer == null) {
    renderResource(requestContext,new ResponseOutput(request,response));
  }
 else {
    TextOnlyStringOutput textOutput=new TextOnlyStringOutput(request,response);
    renderResource(requestContext,textOutput);
    if (!textOutput.hasTextBuffer()) {
      LOG.debug("String_Node_Str" + relUrl + "String_Node_Str");
      return;
    }
    LOG.debug("String_Node_Str" + relUrl + "String_Node_Str");
    String charsetName=textOutput.getCharsetName();
    Writer writer;
    if (charsetName == null)     writer=new OutputStreamWriter(response.getOutputStream());
 else     writer=new OutputStreamWriter(response.getOutputStream(),charsetName);
    renderer.render(textOutput.toString(),writer);
    writer.flush();
  }
}