$ show OpenFeign/feign
OpenFeign/feign is a mature, production-grade Java HTTP client library that enables declarative REST client creation through annotated Java interfaces. It transforms interface definitions into concrete HTTP clients, handling request construction, serialization, transport, and response deserialization. The library supports synchronous, asynchronous (CompletableFuture), and reactive (RxJava, Reactor) programming models, with pluggable backends including OkHttp, Apache HttpClient 5, Java 11 HTTP/2, Vert.x, and the default java.net.HttpURLConnection. Its modular architecture separates concerns into over 30 submodules: core (builder, contract, template engine, codec interfaces), codec implementations (Jackson, Gson, Moshi, Fastjson2, JAXB, SOAP, JSON-java), client transports, resilience (Hystrix circuit breakers, Ribbon load balancing, retry), observability (Micrometer, Dropwizard Metrics, SLF4J), caching, form/multipart encoding, GraphQL, and testing utilities. The library is widely adopted in the Java ecosystem, notably as the foundation for Spring Cloud OpenFeign. Despite its comprehensive feature set and high code quality, the project has an archived lifecycle status per its own metadata, indicating no further active development, with maintenance limited to critical security fixes for the 13.x release line. The codebase exhibits some technical drift, including duplicate modules for Jakarta migration, deprecated Netflix dependencies (Hystrix, Ribbon), and experimental components that may lack long-term support.
The LLM identified 5 files worth highlighting for reuse:
Central builder class that constructs HTTP client proxies from annotated Java interfaces using the Builder pattern. It manages configuration of encoder, decoder, client, contract, interceptors, retryer, error decoder, and capability enrichment. The build process dynamically creates a JDK Proxy that dispatches method invocations to SynchronousMethodHandler or AsynchronousMethodHandler. Demonstrates clean abstraction between configuration (Feign.Builder) and execution (ReflectiveFeign), with extensibility via Capability interface. This is the primary entry point for all Feign usage and embodies the library's core architectural pattern.
Composite decoder that routes to the first matching decoder based on a predicate (e.g., Content-Type). Uses a list of DecoderPredicate pairs to dynamically select the appropriate deserialization strategy per response. Supports chaining with and/or/negate operators for complex content-type matching. This pattern allows extensible codec selection without modifying the core framework, enabling seamless integration of custom decoders alongside built-in ones. A reusable solution for content-negotiation in HTTP clients.
Parses Feign-specific annotations (@RequestLine, @Headers, @Param, @Body, @QueryMap, @HeaderMap) from interface methods and produces MethodMetadata objects. Handles inheritance, parameter expansion, template variables, and method-level overrides. Demonstrates robust annotation reflection and metadata extraction, forming the bridge between declarative API definitions and HTTP request templates. Highly reusable as a pattern for any annotation-driven HTTP client framework.
HTTP client mock implementation for unit testing Feign clients without real HTTP servers. Supports pre-loading responses with status codes, headers, and bodies, and can match requests sequentially or unordered using RequestKey. Provides verification of request counts and bodies after invocation. A self-contained, reusable testing utility that can be extracted and adapted for testing any HTTP client abstraction, not just Feign. Demonstrates careful separation of mock state, matching logic, and assertion helpers.
Declarative error decoder that maps HTTP error codes to custom exceptions using @ErrorHandling and @ErrorCodes annotations on Feign interfaces. Supports class-level and method-level annotations with inheritance and priority rules. Uses @FeignExceptionConstructor to inject response body, headers, and request into generated exceptions. Eliminates boilerplate error handling code by allowing developers to specify exception-to-http-status mappings directly in the API interface. Reusable pattern for any REST client needing rich error semantics.