Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-2218

Unable to set response code of 404 in map:handle-errors

    XMLWordPrintableJSON

Details

    • Normal

    Description

      When an exception is thrown in a pipeline matcher, setting the response status code to 404 has no effect. A 200 is still returned.

      Attached is a block illustrating this issue, run it with "mvn cocoon:prepare jetty:run", and call the following urls:

      http://localhost:8888/status-test/matcher-not-found
      Action: Calls a pattern that is not matched by any matcher in the sitemap. A ResourceNotFoundException is thrown and is handled by map:handle-errors which sets the status to 404.
      Result: 404 status code is correctly returned.

      http://localhost:8888/status-test/404
      Action: Calls a matcher that reads a file, and serializes it setting the response code to 404. No error is thrown, we are simply setting a 404 in a matcher.
      Result: 404 status code is correctly returned.

      http://localhost:8888/status-test/file-not-found
      Action: Calls a matcher that tries to read a non-existent file. A FileNotFoundException is thrown by the generator inside the matcher and is handled by map:handle-errors which sets the status to 404.
      Result: 200 status code is incorrectly returned.

      Please note that this issue only occurs when setting the status to 404, all other status codes seem to be handled correctly.

      I've spent quite a while trying to debug this issue but I can't see the problem, in all cases it looks like the correct status is finally set by org.apache.cocoon.servletservice.HttpServletResponseBufferingWrapper.flushBufferedResponse.

      I tried the suggestions given at http://www.mail-archive.com/users@cocoon.apache.org/msg42494.html but this had no effect.

      Attachments

        1. status-test.zip
          16 kB
          Robin Wyles

        Activity

          People

            Unassigned Unassigned
            rob@robinwyles.com Robin Wyles
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: