@Experimental public interface MethodInterceptor
Contract has resolved
the RequestTemplate from method arguments and before RequestInterceptors mutate
it. Implementations have full access to the raw method arguments, the MethodMetadata, the
resolved RequestTemplate (headers, query params, body bytes), and after MethodInterceptor.Chain.next(Invocation) completes successfully, the Response via Invocation.response().
Use this extension point when RequestInterceptor or ResponseInterceptor are
not enough — typically when you need both the typed argument objects (e.g. for validation) and
the resolved request, or when you need to short-circuit the entire HTTP exchange and return a
value without sending a request.
Short-circuit: simply return a value without calling MethodInterceptor.Chain.next(Invocation).
Exception propagation: any Throwable thrown surfaces to the caller of the Feign
interface method, after retry handling.
public Object intercept(Invocation invocation, Chain chain) throws Throwable {
validate(invocation.arguments());
return chain.next(invocation);
}
| Modifier and Type | Interface and Description |
|---|---|
static interface |
MethodInterceptor.Chain
Contract for delegation to the rest of the chain.
|
| Modifier and Type | Method and Description |
|---|---|
default MethodInterceptor |
andThen(MethodInterceptor next)
Returns a new
MethodInterceptor that invokes the current interceptor first and then the
one passed in. |
default MethodInterceptor.Chain |
apply(MethodInterceptor.Chain chain)
Apply this interceptor to the given chain, producing a chain that runs this interceptor first.
|
Object |
intercept(Invocation invocation,
MethodInterceptor.Chain chain)
Called for every method invocation on a Feign-built proxy.
|
Object intercept(Invocation invocation, MethodInterceptor.Chain chain) throws Throwable
invocation - context for the current method callchain - delegate to invoke the rest of the pipeline (request interceptors, HTTP, response
interceptors, decoder)Throwabledefault MethodInterceptor.Chain apply(MethodInterceptor.Chain chain)
default MethodInterceptor andThen(MethodInterceptor next)
MethodInterceptor that invokes the current interceptor first and then the
one passed in.Copyright © 2012–2026 OpenFeign. All rights reserved.