FeignInvocationHandler class final

The engine behind one @FeignClient interface: the generated class hands every method call to it, and it makes the HTTP call.

For each call it builds a RequestTemplate from the method's mapping annotations and the arguments, lets the interceptors change it, adds the configured default headers and query parameters, and sends it through the transport. A 2xx answer is decoded into the method's return type with the mapper; another status becomes an exception through the errorDecoder. A RetryableException (no connection, a timeout, a Retry-After) is tried again as long as the retryer allows, each attempt on a new template. When the call still fails and the client has a fallback, the fallback bean answers instead.

Methods returning EventStream<T> (or Stream<T>) read text/event-stream responses: each listener opens its own connection, every event's data is decoded into T, and a lost connection is opened again with Last-Event-ID (see FeignClientConfig.eventStreamReconnect).

The starter's FeignClientFactory creates one per client bean; applications never create or call it, they call the interface. Every method is checked at creation, so a path variable without a parameter or a method without a mapping stops the application at startup with the reason.

Spring (Java): Feign's SynchronousMethodHandler behind the proxy that FeignClientFactoryBean creates.

Implemented types

Constructors

FeignInvocationHandler({required InterfaceMetadata<Object> metadata, required FeignClient client, required FeignClientConfig config, required Environment environment, required ObjectMapper mapper, required HttpTransport transport, List<RequestInterceptor> interceptors = const [], ErrorDecoder errorDecoder = const DefaultErrorDecoder(), Retryer retryer = Retryer.never, Object fallback()?})
The handler of the interface described by metadata. Throws a StateError listing every problem found in its methods, or when no URL is configured.

Properties

client → FeignClient
The interface's @FeignClient annotation.
final
config → FeignClientConfig
The client's settings from spring.feign.client.config.*.
final
dismiss404 → bool
Whether a 404 gives an empty result instead of an exception: set by @FeignClient(dismiss404: true) or the dismiss404 property. For an event stream, a dismissed 404 ends the stream.
no setter
environment → Environment
Resolves the ${...} placeholders of the URL, the paths and the mapping headers.
final
errorDecoder → ErrorDecoder
Turns a response with an error status into the exception the call throws.
final
fallback → Object Function()?
Gives the fallback bean that answers when a call fails; it is looked up at the first failure. null when the client has none.
final
hashCode → int
The hash code for this object.
no setterinherited
interceptors → List<RequestInterceptor>
Change every request before it is sent, in this order, at every attempt.
final
mapper → ObjectMapper
Writes request bodies as JSON and reads response bodies.
final
retryer → Retryer
Decides whether and when a failed attempt is tried again; by default never.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transport → HttpTransport
Sends the requests.
final
typeName → String
The name of the interface, such as CatalogClient; the logger is feign.<typeName>.
final

Methods

invoke(ProxyMethod method, List<Object?> arguments) → Object?
Handles a call of method with arguments and returns its result: a Future of the value for methods that return one (ProxyMethod.isFuture). What it throws reaches the caller.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited