Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-2623

RenderingFilter logs a "Unable to redirect to 404 page, response is already committed" any time there is an error while streaming back a resource

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • 4.0
    • 4.0
    • core
    • None

      This is really trivial, the problem is just a spurious log.info().
      In RenderingFilter there is a catch for IOExceptions while streaming back resources. The exception is swallowed since it's typically a ClientAbortException (can happen). But after the catch there is no "return" and the flow continues just like the resource was not found.
      The filter tries to forward to the 404 page, than it catches another exception due to the closed stream and log another info.

                  catch (IOException e) {
                      // don't log at error level since tomcat tipically throws a
                      // org.apache.catalina.connector.ClientAbortException if the user stops loading the page
                      log.debug("Exception while dispatching resource " + e.getClass().getName() + ": " + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$
                  }
                  catch (Exception e) {
                      log.error("Exception while dispatching resource  " + e.getClass().getName() + ": " + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$
                  }
                  finally {
                      IOUtils.closeQuietly(is);
                  }
      
               // missing return here
      
              }
      
              log.debug("Resource not found, redirecting request for [{}] to 404 URI", request.getRequestURI()); //$NON-NLS-1$
      
              if (!response.isCommitted()) {
                  response.sendError(HttpServletResponse.SC_NOT_FOUND);
              }
              else {
                  log.info("Unable to redirect to 404 page, response is already committed"); //$NON-NLS-1$
              }
      
      

        Acceptance criteria

              fgiust Fabrizio Giustina
              fgiust Fabrizio Giustina
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD