Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-541

Handling of MethodNotAllowedException if RESTeasy is a Filter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.RC1
    • 2.1.0.GA
    • jaxrs
    • None

      Surroundings:

      • RESTeasy is registered as filter (web.xml -> FilterDispatcher)
      • The requested resource exists with GET and POST method

      Problem:
      Running a request with e.g. PUT results in a MethodNotAllowedException in org.jboss.resteasy.core.registry.Segment.match(String, MediaType, List<MediaType>).
      This exception is not catched in RESTeasy and bubbles up the complete stack until the server creates 500 with an exception page.

      Cause:
      This happens because in org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(HttpRequest, HttpResponse) the getInvoker is outside of the try/catch block so the exception goes up to org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(ServletRequest, ServletResponse, FilterChain), but there only a NotFoundException is catched. Since NotFoundException and MethodNotAllowedException don't derive from each other the exception bubbles up outside of RESTeasy.

      Solution proposal:
      In my opinion the MethodNotAllowedException should be handled the normal way (405 response). To do this getInvoker in SynchronousDispatcher.invokePropagateNotFound should be surrounded by a try/catch MethodNotAllowedException and in catch run the normal handleException process.

              patriot1burke@gmail.com Bill Burke (Inactive)
              NvtMorch Holger Morch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: