users@jersey.java.net

[Jersey] ClientRequestFilter and abortWith()

From: Mark Petrovic <mspetrovic_at_gmail.com>
Date: Fri, 4 Apr 2014 07:10:48 -0700

Hi.

I am experimenting with the Jersey 2.7 client-side
ClientRequestFilter, and have the following code:

    public void filter(ClientRequestContext requestContext) throws IOException {
        String authorizationHeader =
requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
        if (!StringUtils.isEmpty(authorizationHeader)) {
            requestContext.abortWith(Response.status(Response.Status.BAD_REQUEST).entity("Client
filter reserves the right to set Authorization header").build());
        }
        ...
    }

I find that if the requestContext.abortWith() method is called
processing does not actually stop, but continues past the
if-statement. This is contrary to what the documentation says here:

https://jersey.java.net/documentation/latest/user-guide.html#d0e8176

Would someone be kind enough to suggest what I might be doing wrong?

Thank you.

-- 
Mark