Program: 90592
Project: 90592
Buggy source:
private void doDispatch(PortletRequest request,PortletResponse response,boolean included) throws PortletException, IOException {
  boolean needsFlushAfterForward=false;
  if (!included) {
    String lifecyclePhase=(String)request.getAttribute(PortletRequest.LIFECYCLE_PHASE);
    if (PortletRequest.RENDER_PHASE.equals(lifecyclePhase) || PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase)) {
      needsFlushAfterForward=true;
      ((MimeResponse)response).resetBuffer();
    }
  }
  PortletRequestContext requestContext=(PortletRequestContext)request.getAttribute(PortletInvokerService.REQUEST_CONTEXT);
  HttpSession session=null;
  if (isPortletScopeSessionConfigured(requestContext)) {
    String portletWindowId=requestContext.getPortletWindow().getId().getStringId();
    session=ServletPortletSessionProxy.createProxy(requestContext.getServletRequest(),portletWindowId);
  }
  HttpServletPortletRequestWrapper req=new HttpServletPortletRequestWrapper(requestContext.getServletRequest(),requestContext.getServletContext(),session,request,included,namedDispatch);
  HttpServletPortletResponseWrapper res=new HttpServletPortletResponseWrapper(requestContext.getServletResponse(),request,response,included);
  try {
    request.setAttribute(PortletInvokerService.PORTLET_CONFIG,requestContext.getPortletConfig());
    request.setAttribute(PortletInvokerService.PORTLET_REQUEST,request);
    request.setAttribute(PortletInvokerService.PORTLET_RESPONSE,response);
    if (!included && req.isForwardingPossible()) {
      requestDispatcher.forward(req,res);
    }
 else {
      requestDispatcher.include(req,res);
    }
    if (needsFlushAfterForward) {
      ((MimeResponse)response).flushBuffer();
    }
  }
 catch (  ServletException sex) {
    if (sex.getRootCause() != null) {
      throw new PortletException(sex.getRootCause());
    }
    throw new PortletException(sex);
  }
 finally {
    request.removeAttribute(PortletInvokerService.PORTLET_CONFIG);
    request.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
    request.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
  }
}

Fixed version (ground truth):
private void doDispatch(PortletRequest request,PortletResponse response,boolean included) throws PortletException, IOException {
  boolean needsFlushAfterForward=false;
  if (!included) {
    String lifecyclePhase=(String)request.getAttribute(PortletRequest.LIFECYCLE_PHASE);
    if (PortletRequest.RENDER_PHASE.equals(lifecyclePhase) || PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase)) {
      needsFlushAfterForward=true;
      ((MimeResponse)response).resetBuffer();
    }
  }
  PortletRequestContext requestContext=(PortletRequestContext)request.getAttribute(PortletInvokerService.REQUEST_CONTEXT);
  HttpSession session=null;
  if (isPortletScopeSessionConfigured(requestContext)) {
    String portletWindowId=requestContext.getPortletWindow().getId().getStringId();
    session=ServletPortletSessionProxy.createProxy(requestContext.getServletRequest(),portletWindowId);
  }
  HttpServletPortletRequestWrapper req=new HttpServletPortletRequestWrapper(requestContext.getServletRequest(),requestContext.getServletContext(),session,request,included,namedDispatch);
  HttpServletPortletResponseWrapper res=new HttpServletPortletResponseWrapper(requestContext.getServletResponse(),request,response,included);
  boolean executingReqBody=requestContext.isExecutingRequestBody();
  requestContext.setExecutingRequestBody(false);
  try {
    request.setAttribute(PortletInvokerService.PORTLET_CONFIG,requestContext.getPortletConfig());
    request.setAttribute(PortletInvokerService.PORTLET_REQUEST,request);
    request.setAttribute(PortletInvokerService.PORTLET_RESPONSE,response);
    if (!included && req.isForwardingPossible()) {
      requestDispatcher.forward(req,res);
    }
 else {
      requestDispatcher.include(req,res);
    }
    if (needsFlushAfterForward) {
      ((MimeResponse)response).flushBuffer();
    }
  }
 catch (  ServletException sex) {
    if (sex.getRootCause() != null) {
      throw new PortletException(sex.getRootCause());
    }
    throw new PortletException(sex);
  }
 finally {
    request.removeAttribute(PortletInvokerService.PORTLET_CONFIG);
    request.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
    request.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
    requestContext.setExecutingRequestBody(executingReqBody);
  }
}