Skip to content

[Issue 1487] Fix ErrorDecoder not invoked for Apache HttpClient checked exceptions#3338

Open
gitshabh wants to merge 1 commit intoOpenFeign:masterfrom
gitshabh:fixCheckedExceptionUnwrapping
Open

[Issue 1487] Fix ErrorDecoder not invoked for Apache HttpClient checked exceptions#3338
gitshabh wants to merge 1 commit intoOpenFeign:masterfrom
gitshabh:fixCheckedExceptionUnwrapping

Conversation

@gitshabh
Copy link
Copy Markdown

@gitshabh gitshabh commented May 1, 2026

Problem

When Apache HttpClient throws checked exceptions like ProtocolException (e.g., missing Location header on 303 redirect), the ErrorDecoder was never invoked because the exception occurred during client.execute() before a Response object was created.

Root Cause

The ErrorDecoder interface requires a Response object: [Exception decode(String methodKey, Response response)]. When execution fails with checked exceptions, there's no Response to pass, causing the exception to propagate uncaught and potentially get wrapped in UndeclaredThrowableException.

Solution:

Build Response with appropriate status codes in case of ProtocolException instead of throwing exception so that error decoder can be invoked.

@gitshabh gitshabh force-pushed the fixCheckedExceptionUnwrapping branch from b0a9252 to 1c47c11 Compare May 2, 2026 12:46
@gitshabh gitshabh changed the title Avoid UndeclaredThrowableException when UNWRAP unwraps checked causes [Issue 1487] Fix ErrorDecoder not invoked for Apache HttpClient checked exceptions May 2, 2026
@gitshabh
Copy link
Copy Markdown
Author

gitshabh commented May 2, 2026

@velo
Hi, we can see the "Redirection but no location header" in the FeignException instead of UndeclaredThrowableException. Do you think this solution is correct?

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.

1 participant