@Beta @Contract @ConstrainedTo(value=CLIENT) public interface PostInvocationInterceptor
ClientResponseFilters
are executed.
It is ensured that all PostInvocationInterceptors
are executed after the request, in the reverse order given by the
Priority
, the higher the priority the later the execution. Any Throwable
thrown when
the afterRequest(ClientRequestContext, ClientResponseContext)
or
onException(ClientRequestContext, ExceptionContext)
is being processed is accumulated and
a multi RuntimeException with other exceptions supressed
is being thrown at the end
(possibly encapsulated in a ProcessingException
if not a single RuntimeException
),
unless resolved by onException(ClientRequestContext, ExceptionContext)
. During the
PostInvocationInterceptor
processing, the accumulated Deque
of the Throwables
is available in the
PostInvocationInterceptor.ExceptionContext
.
For asynchronous invocation, the PostInvocationInterceptor
is invoked in the request thread, i.e. in the thread
provided by ExecutorService
.
When the lowest priority PostInvocationInterceptor
is executed first, one of the two methods can be invoked.
afterRequest(ClientRequestContext, ClientResponseContext)
in a usual case when no previous
Throwable
was caught, or onException(ClientRequestContext, ExceptionContext)
when
the Throwable
was caught. Should the PostInvocationInterceptor.ExceptionContext.resolve(Response)
be utilized in that case,
the next PostInvocationInterceptor
's
afterRequest
method will be
invoked. Similarly, when a Throwable
is caught during the PostInvocationInterceptor
execution, the next
PostInvocationInterceptor
's
onException
method will be invoked.Modifier and Type | Interface and Description |
---|---|
static interface |
PostInvocationInterceptor.ExceptionContext
The context providing information when the
Throwable (typically, the RuntimeException ) is caught. |
Modifier and Type | Method and Description |
---|---|
void |
afterRequest(ClientRequestContext requestContext,
ClientResponseContext responseContext)
The method is invoked after a request when no
Throwable is thrown, or the Throwables are
resolved by previous PostInvocationInterceptor . |
void |
onException(ClientRequestContext requestContext,
PostInvocationInterceptor.ExceptionContext exceptionContext)
The method is invoked after a
Throwable is caught during the client request chain processing. |
void afterRequest(ClientRequestContext requestContext, ClientResponseContext responseContext)
Throwable
is thrown, or the Throwables
are
resolved
by previous PostInvocationInterceptor
.void onException(ClientRequestContext requestContext, PostInvocationInterceptor.ExceptionContext exceptionContext)
Throwable
is caught during the client request chain processing.requestContext
- the request context.exceptionContext
- the context available to handle the caught Throwables
.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.