Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6368

Unexpected response code

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.3
    • Fix Version/s: 3.1, 3.0.5
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Advanced

      Description

      Come from a TCK test:
      The excepted response code was 500, but got 200.
      The application is like this:
      Throw a RuntimeException from a ContainerResponseFilter
      public class CustomFilter implements ContainerResponseFilter {
      @Override
      public void filter(ContainerRequestContext requestContext,
      ContainerResponseContext responseContext) throws IOException

      { throw new RuntimeException("exception From custom ContainerResponseFilter"); }

      }
      }

      A RuntimeExceptionMapper mapped the exception and set response code to 200.

      @Provider
      public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
      @Override
      public Response toResponse(RuntimeException exception)

      { return Response.ok(message).build(); }

      }

      The filter was called first time, throw the exception, exception mapper mapped it.
      When running method serializeMessage() in JAXRSOutInterceptor, the filer was called the second time, throw the exception again. In method handleWriteException() of JAXRSOutInterceptor, becasue firstTry=false, the exception was not mapped this time, setResponseStatus() was called.
      In JAXRSDefaultFaultOutInterceptor, the method JAXRSUtils.convertFaultToResponse() was called, the exception was mapped again. Then in method serializeMessage(), the filter was called the third time. RuntimeExceptionMapper mapped again. Then method serializeMessage() was called again, then the filter was called the fourth time, throw exception fourth time. Becasue firstTry=false, the exception was not mapped this time, setResponseStatus() was called.
      Now in message, can found response status is 500. But later the response status 500 was lost when set oldMessage back.

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              weiz Wei Zheng
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: