Skip to content

Forward dismiss404 from CoroutineFeign builder to AsyncFeign#3371

Open
seonwoo-jung wants to merge 1 commit into
OpenFeign:masterfrom
seonwoo-jung:fix/2026-coroutinefeign-dismiss404
Open

Forward dismiss404 from CoroutineFeign builder to AsyncFeign#3371
seonwoo-jung wants to merge 1 commit into
OpenFeign:masterfrom
seonwoo-jung:fix/2026-coroutinefeign-dismiss404

Conversation

@seonwoo-jung
Copy link
Copy Markdown

CoroutineFeign.CoroutineBuilder inherits dismiss404() from BaseBuilder, but internalBuild() constructed a fresh AsyncFeign.builder() chain that never forwarded the flag. As a result, calling .dismiss404() on a coroutine builder silently had no effect — a 404 response still produced a FeignException instead of being routed through the decoder.

Fix

Split the existing builder chain so the configured dismiss404 value is applied to the underlying AsyncBuilder before build():

AsyncFeign.AsyncBuilder<Object> asyncBuilder =
    AsyncFeign.builder()
        .logLevel(logLevel)
        ...
        .methodInfoResolver(methodInfoResolver);
if (dismiss404) {
  asyncBuilder.dismiss404();
}
AsyncFeign<C> asyncFeign = (AsyncFeign<C>) asyncBuilder.build();

The conditional mirrors BaseBuilder.dismiss404() semantics (a one-way switch); preserving the default false behavior when the user doesn't opt in.

Test

Adds CoroutineFeignTest.\sut should dismiss 404 responses when dismiss404 is configured on CoroutineBuilder`, modeled on AsyncFeignTest.decodingDoesNotSwallow404ErrorsInDismiss404Mode. The test enqueues a 404, installs a recording Decoder`, and asserts that:

  1. The call does not throw a FeignException.
  2. The decoder is invoked with response.status() == 404, proving the dismiss-404 path engaged.

Without the fix, the call would throw on the 404 before the decoder is ever called.

Fixes #2026

CoroutineFeign.CoroutineBuilder inherits the dismiss404 setter from
BaseBuilder, but internalBuild() created a fresh AsyncFeign.builder()
chain that never forwarded the flag, so dismiss404() configured on a
CoroutineBuilder had no effect at runtime: a 404 response still
produced a FeignException instead of being passed to the decoder.

Split the chain so the configured dismiss404 value is applied to the
underlying AsyncBuilder before build(). Adds a unit test that verifies
the decoder is invoked for a 404 response when dismiss404 is set on
the CoroutineBuilder.

Fixes OpenFeign#2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feign-kotlin: dismiss404 doesn't work in CoroutineFeign

1 participant