Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5053

IllegalArgumentException when forwarding request

    XMLWordPrintableJSON

Details

    Description

      It seems to be a problem with forwarding requests in certain cases. I have the following setup:

      • Servlet A forwards the request to Servlet 2 (using RequestDispatcher).
      • Servlet B writes to the response using an output stream (HttpServletResponse.getOutputStream()).

      When this happens I get an IllegalStateException from Jetty that basically saying that the Writer cannot be closed since I have already used an OutputStream.

      The code that I think is wrong (or possibly not robust enough) is in RequestDispatcherImp line 84.

      if (!request.isAsyncStarted())
      {
        response.flushBuffer();
        response.getWriter().close();
      }
      

      The line that causes trouble is:

      response.getWriter().close();
      

      We should probably check if we can actually close this writer or just ignore the potential exception.

      In my setup I have one servlet that writes to OutputStream using HttpServletResponse.getOutputStream(). Then I have another servlet that forwards the request to the first servlet.

      Attachments

        Activity

          People

            srs Sten Roger Sandvik
            srs Sten Roger Sandvik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: