1 Reply Latest reply on Aug 13, 2012 3:50 PM by gilby

    RestEasy PostProcessInterceptor chain not traversed if response is created by ExceptionMapper

    rushead

      Hi all.

       

      A little explanation before:

      I had a problem with my custom logging implementation (based on a ServletFilter) which is caused by the fact that the HttpHeader entries are applied at the HttpServletResponse right before the message body is written.

      Therefore I wanted to implement a PostProcessInterceptor which applies the necessary HttpHeader entries, which are already contained in the ServerResponse, at the injected HttpServletResponse.

       

      If the resource does not throw an exception my implementation works as expected.

      If an exception is thrown and an ExceptionMapper is creating the response, the PostProcessInterceptor chain is not traversed.

       

      In my opinion the problem is caused by the following line in resteasy-jaxrs:

      https://github.com/resteasy/Resteasy/blob/master/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/SynchronousDispatcher.java#L335

      The interceptor chain is not applied to the created Response before writing / sending it.

       

      My question is now:

      Is this an expected behavior? In my opinion the interceptor chain should be traversed in every case.

      I didn't create a new issue in the resteasy jira because I'm not sure if this behavior is expected.

       

      My current workaround:

      Currently I create the interceptor, inject the properties and add it to the response within my abstract ExceptionMapper implementation. (<-- quite ugly, I know...)

       

      Thanking you in anticipation.