Program: 90591
Project: 90591
Buggy source:
/** 
 * Dispatch the request to the appropriate portlet methods. This method assumes that the following attributes are set in the servlet request scope: <ul> <li>METHOD_ID: indicating which method to dispatch.</li> <li>PORTLET_REQUEST: the internal portlet request.</li> <li>PORTLET_RESPONSE: the internal portlet response.</li> </ul>
 * @param request the servlet request.
 * @param response the servlet response.
 * @throws ServletException
 * @throws IOException
 */
private void dispatch(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  if (LOG.isDebugEnabled()) {
    StringBuilder txt=new StringBuilder();
    txt.append("String_Node_Str");
    txt.append("String_Node_Str").append(request.getDispatcherType());
    txt.append("String_Node_Str").append(request.getRequestURI());
    LOG.debug(txt.toString());
  }
  if (invoker == null) {
    throw new javax.servlet.UnavailableException("String_Node_Str" + portletName + "String_Node_Str");
  }
  Integer methodId=(Integer)request.getAttribute(PortletInvokerService.METHOD_ID);
  final PortletRequest portletRequest=(PortletRequest)request.getAttribute(PortletInvokerService.PORTLET_REQUEST);
  final PortletResponse portletResponse=(PortletResponse)request.getAttribute(PortletInvokerService.PORTLET_RESPONSE);
  final PortletRequestContext requestContext=(PortletRequestContext)portletRequest.getAttribute(PortletInvokerService.REQUEST_CONTEXT);
  final PortletResponseContext responseContext=(PortletResponseContext)portletRequest.getAttribute(PortletInvokerService.RESPONSE_CONTEXT);
  final FilterManager filterManager=(FilterManager)request.getAttribute(PortletInvokerService.FILTER_MANAGER);
  if (LOG.isTraceEnabled()) {
    StringBuilder txt=new StringBuilder(128);
    txt.append("String_Node_Str");
    ServletRequest wreq=request;
    ServletRequest tstreq=requestContext.getServletRequest();
    int n=1;
    while (wreq instanceof ServletRequestWrapper) {
      txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wreq.getClass().getCanonicalName());
      txt.append("String_Node_Str").append(wreq.getDispatcherType());
      txt.append("String_Node_Str").append(wreq == tstreq);
      wreq=((ServletRequestWrapper)wreq).getRequest();
    }
    txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wreq.getClass().getCanonicalName());
    txt.append("String_Node_Str").append(wreq.getDispatcherType());
    txt.append("String_Node_Str").append(wreq == tstreq);
    txt.append("String_Node_Str");
    ServletResponse wresp=response;
    ServletResponse tstresp=requestContext.getServletResponse();
    n=1;
    while (wresp instanceof ServletResponseWrapper) {
      txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wresp.getClass().getCanonicalName());
      txt.append("String_Node_Str").append(wresp == tstresp);
      wresp=((ServletResponseWrapper)wresp).getResponse();
    }
    txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wresp.getClass().getCanonicalName());
    txt.append("String_Node_Str").append(wresp == tstresp);
    LOG.debug(txt.toString());
  }
  if (request.getDispatcherType() == DispatcherType.ASYNC) {
    ServletRequest wreq=request;
    while ((wreq instanceof ServletRequestWrapper) && !(wreq instanceof PortletAsyncRequestWrapper)) {
      wreq=((ServletRequestWrapper)wreq).getRequest();
    }
    if (wreq instanceof PortletAsyncRequestWrapper) {
      HttpServletRequest hreq=(HttpServletRequest)((PortletAsyncRequestWrapper)wreq).getRequest();
      HttpServletResponse hresp=requestContext.getServletResponse();
      LOG.debug("String_Node_Str" + hreq.getDispatcherType());
      requestContext.init(portletConfig,getServletContext(),hreq,hresp);
      responseContext.init(hreq,hresp);
    }
 else {
      LOG.debug("String_Node_Str");
    }
  }
 else {
    requestContext.init(portletConfig,getServletContext(),request,response);
    responseContext.init(request,response);
  }
  PortletWindow window=requestContext.getPortletWindow();
  PortletInvocationEvent event=new PortletInvocationEvent(portletRequest,window,methodId.intValue());
  notify(event,true,null);
  try {
    if (methodId == PortletInvokerService.METHOD_RENDER) {
      RenderRequest renderRequest=(RenderRequest)portletRequest;
      String rh=requestContext.getRenderHeaders();
      if (rh != null) {
        renderRequest.setAttribute(PortletRequest.RENDER_PART,rh);
      }
      RenderResponse renderResponse=(RenderResponse)portletResponse;
      filterManager.processFilter(renderRequest,renderResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_HEADER) {
      HeaderRequest headerRequest=(HeaderRequest)portletRequest;
      HeaderResponse headerResponse=(HeaderResponse)portletResponse;
      filterManager.processFilter(headerRequest,headerResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_RESOURCE) {
      ResourceRequest resourceRequest=(ResourceRequest)portletRequest;
      PortletResourceRequestContext rc=(PortletResourceRequestContext)requestContext;
      String ps=rc.getPageState();
      if (ps != null) {
        resourceRequest.setAttribute(ResourceRequest.PAGE_STATE,ps);
      }
      ResourceResponse resourceResponse=(ResourceResponse)portletResponse;
      filterManager.processFilter(resourceRequest,resourceResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_ACTION) {
      ActionRequest actionRequest=(ActionRequest)portletRequest;
      ActionResponse actionResponse=(ActionResponse)portletResponse;
      filterManager.processFilter(actionRequest,actionResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_EVENT) {
      EventRequest eventRequest=(EventRequest)portletRequest;
      EventResponse eventResponse=(EventResponse)portletResponse;
      filterManager.processFilter(eventRequest,eventResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_ADMIN) {
      PortalAdministrationService pas=PlutoServices.getServices().getPortalAdministrationService();
      for (      AdministrativeRequestListener l : pas.getAdministrativeRequestListeners()) {
        l.administer(portletRequest,portletResponse);
      }
    }
 else     if (methodId == PortletInvokerService.METHOD_LOAD) {
    }
    notify(event,false,null);
  }
 catch (  UnavailableException ex) {
    try {
      invoker.destroy();
    }
 catch (    Throwable th) {
      this.getServletContext().log("String_Node_Str",th);
    }
    invoker=null;
    throw new javax.servlet.UnavailableException(ex.getMessage());
  }
catch (  PortletException ex) {
    notify(event,false,ex);
    throw new ServletException(ex);
  }
 finally {
    if (!request.isAsyncStarted() && (request.getDispatcherType() != DispatcherType.ASYNC)) {
      request.removeAttribute(PortletInvokerService.METHOD_ID);
      request.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
      request.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
      request.removeAttribute(PortletInvokerService.FILTER_MANAGER);
    }
  }
}

Fixed version (ground truth):
/** 
 * Dispatch the request to the appropriate portlet methods. This method assumes that the following attributes are set in the servlet request scope: <ul> <li>METHOD_ID: indicating which method to dispatch.</li> <li>PORTLET_REQUEST: the internal portlet request.</li> <li>PORTLET_RESPONSE: the internal portlet response.</li> </ul>
 * @param request the servlet request.
 * @param response the servlet response.
 * @throws ServletException
 * @throws IOException
 */
private void dispatch(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  if (LOG.isDebugEnabled()) {
    StringBuilder txt=new StringBuilder();
    txt.append("String_Node_Str");
    txt.append("String_Node_Str").append(request.getDispatcherType());
    txt.append("String_Node_Str").append(request.getRequestURI());
    LOG.debug(txt.toString());
  }
  if (invoker == null) {
    throw new javax.servlet.UnavailableException("String_Node_Str" + portletName + "String_Node_Str");
  }
  Integer methodId=(Integer)request.getAttribute(PortletInvokerService.METHOD_ID);
  final PortletRequest portletRequest=(PortletRequest)request.getAttribute(PortletInvokerService.PORTLET_REQUEST);
  final PortletResponse portletResponse=(PortletResponse)request.getAttribute(PortletInvokerService.PORTLET_RESPONSE);
  final PortletRequestContext requestContext=(PortletRequestContext)portletRequest.getAttribute(PortletInvokerService.REQUEST_CONTEXT);
  final PortletResponseContext responseContext=(PortletResponseContext)portletRequest.getAttribute(PortletInvokerService.RESPONSE_CONTEXT);
  final FilterManager filterManager=(FilterManager)request.getAttribute(PortletInvokerService.FILTER_MANAGER);
  if (LOG.isTraceEnabled()) {
    StringBuilder txt=new StringBuilder(128);
    txt.append("String_Node_Str");
    ServletRequest wreq=request;
    ServletRequest tstreq=requestContext.getServletRequest();
    int n=1;
    while (wreq instanceof ServletRequestWrapper) {
      txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wreq.getClass().getCanonicalName());
      txt.append("String_Node_Str").append(wreq.getDispatcherType());
      txt.append("String_Node_Str").append(wreq == tstreq);
      wreq=((ServletRequestWrapper)wreq).getRequest();
    }
    txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wreq.getClass().getCanonicalName());
    txt.append("String_Node_Str").append(wreq.getDispatcherType());
    txt.append("String_Node_Str").append(wreq == tstreq);
    txt.append("String_Node_Str");
    ServletResponse wresp=response;
    ServletResponse tstresp=requestContext.getServletResponse();
    n=1;
    while (wresp instanceof ServletResponseWrapper) {
      txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wresp.getClass().getCanonicalName());
      txt.append("String_Node_Str").append(wresp == tstresp);
      wresp=((ServletResponseWrapper)wresp).getResponse();
    }
    txt.append("String_Node_Str").append(n++).append("String_Node_Str").append(wresp.getClass().getCanonicalName());
    txt.append("String_Node_Str").append(wresp == tstresp);
    LOG.debug(txt.toString());
  }
  if (request.getDispatcherType() == DispatcherType.ASYNC) {
    ServletRequest wreq=request;
    while ((wreq instanceof ServletRequestWrapper) && !(wreq instanceof PortletAsyncRequestWrapper)) {
      wreq=((ServletRequestWrapper)wreq).getRequest();
    }
    if (wreq instanceof PortletAsyncRequestWrapper) {
      HttpServletRequest hreq=(HttpServletRequest)((PortletAsyncRequestWrapper)wreq).getRequest();
      HttpServletResponse hresp=requestContext.getServletResponse();
      LOG.debug("String_Node_Str" + hreq.getDispatcherType());
      requestContext.init(portletConfig,getServletContext(),hreq,hresp);
      responseContext.init(hreq,hresp);
    }
 else {
      LOG.debug("String_Node_Str");
    }
  }
 else {
    requestContext.init(portletConfig,getServletContext(),request,response);
    requestContext.setExecutingRequestBody(true);
    responseContext.init(request,response);
  }
  PortletWindow window=requestContext.getPortletWindow();
  PortletInvocationEvent event=new PortletInvocationEvent(portletRequest,window,methodId.intValue());
  notify(event,true,null);
  try {
    if (methodId == PortletInvokerService.METHOD_RENDER) {
      RenderRequest renderRequest=(RenderRequest)portletRequest;
      String rh=requestContext.getRenderHeaders();
      if (rh != null) {
        renderRequest.setAttribute(PortletRequest.RENDER_PART,rh);
      }
      RenderResponse renderResponse=(RenderResponse)portletResponse;
      filterManager.processFilter(renderRequest,renderResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_HEADER) {
      HeaderRequest headerRequest=(HeaderRequest)portletRequest;
      HeaderResponse headerResponse=(HeaderResponse)portletResponse;
      filterManager.processFilter(headerRequest,headerResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_RESOURCE) {
      ResourceRequest resourceRequest=(ResourceRequest)portletRequest;
      PortletResourceRequestContext rc=(PortletResourceRequestContext)requestContext;
      String ps=rc.getPageState();
      if (ps != null) {
        resourceRequest.setAttribute(ResourceRequest.PAGE_STATE,ps);
      }
      ResourceResponse resourceResponse=(ResourceResponse)portletResponse;
      filterManager.processFilter(resourceRequest,resourceResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_ACTION) {
      ActionRequest actionRequest=(ActionRequest)portletRequest;
      ActionResponse actionResponse=(ActionResponse)portletResponse;
      filterManager.processFilter(actionRequest,actionResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_EVENT) {
      EventRequest eventRequest=(EventRequest)portletRequest;
      EventResponse eventResponse=(EventResponse)portletResponse;
      filterManager.processFilter(eventRequest,eventResponse,invoker,portletContext);
    }
 else     if (methodId == PortletInvokerService.METHOD_ADMIN) {
      PortalAdministrationService pas=PlutoServices.getServices().getPortalAdministrationService();
      for (      AdministrativeRequestListener l : pas.getAdministrativeRequestListeners()) {
        l.administer(portletRequest,portletResponse);
      }
    }
 else     if (methodId == PortletInvokerService.METHOD_LOAD) {
    }
    notify(event,false,null);
  }
 catch (  UnavailableException ex) {
    try {
      invoker.destroy();
    }
 catch (    Throwable th) {
      this.getServletContext().log("String_Node_Str",th);
    }
    invoker=null;
    throw new javax.servlet.UnavailableException(ex.getMessage());
  }
catch (  PortletException ex) {
    notify(event,false,ex);
    throw new ServletException(ex);
  }
 finally {
    requestContext.setExecutingRequestBody(false);
    if (!request.isAsyncStarted()) {
      LOG.debug("String_Node_Str" + requestContext.isExecutingRequestBody());
      if (request.getDispatcherType() != DispatcherType.ASYNC) {
        request.removeAttribute(PortletInvokerService.METHOD_ID);
        request.removeAttribute(PortletInvokerService.PORTLET_REQUEST);
        request.removeAttribute(PortletInvokerService.PORTLET_RESPONSE);
        request.removeAttribute(PortletInvokerService.FILTER_MANAGER);
      }
    }
 else {
      LOG.debug("String_Node_Str" + requestContext.isExecutingRequestBody());
    }
  }
}