Uploaded image for project: 'Pluto'
  1. Pluto
  2. PLUTO-641

Empty Portlet when using the forward to include fallback mechanism

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.3
    • None
    • portlet container
    • None

    Description

      While working on the SPR-12374 Spring bug report, I may have find a bug in the forward to include fallback mechanism of Apache Pluto.

      In PortletRequestDispatcherImpl#forward(), req.setNestedForward() is called whether forwarding is possible or not, so even if requestDispatcher.include(request, response) is called, the forwarded attribute is set to true.

      As a consequence, in HttpServletPortletRequestWrapper#setupFirstDispatchPathValues(), the forward request attributes are used instead of the include ones, and the JSP is never rendered.

      In order to fix that, my proposal (untested) would be modify the PortletRequestDispatcherImpl#forward() implementation to:

      public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException
      {
      	HttpServletPortletRequestWrapper req = getWrappedRequest(request);
      	HttpServletPortletResponseWrapper res = getWrappedResponse(response);
      	res.resetBuffer();
      
      	// cache the current dispatch state
      	boolean forwarded = req.isForwarded();
      	boolean namedDispatch = req.isNamedDispatch();
      	Map<String,Object> pathAttributeValues = req.getPathAttributeValues();
      	HttpServletPortletRequestWrapper.PathMethodValues pathMethodValues = req.getInitPathMethodValues();
      
      	if (req.isForwardingPossible())
      	{
      		// (re)initialize the request wrapper to a nested forward
      		req.setNestedForward();
      		try
      		{
      			requestDispatcher.forward(request, response);		
      		}
      		finally
      		{
      			// restore the previously cached dispatch state
      			req.restoreFromNestedForward(forwarded, namedDispatch, pathMethodValues, pathAttributeValues);
      		}
      	}
      	else
      	{
      		// need to "fake" the forward using an include
      		requestDispatcher.include(request, response);
      	}
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            sdeleuze S├ębastien Deleuze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: