Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry issue after migration to 13.5 #2689

Open
sergey-morenets opened this issue Dec 9, 2024 · 2 comments
Open

Retry issue after migration to 13.5 #2689

sergey-morenets opened this issue Dec 9, 2024 · 2 comments

Comments

@sergey-morenets
Copy link

Hi

We use feign-java11 and feign-gson dependencies in our project and after we migrated from 13.1 to 13.5 one of our tests started failing.
This test uses WireMock and verifies that if malformed response is sent to the client then RetryableException is thrown.

extension.stubFor(post(urlEqualTo("/cities")).willReturn(aResponse().withFault(Fault.MALFORMED_RESPONSE_CHUNK)));
assertThrows(RetryableException.class, () -> cityClient.create(city));

In 13.1 this test passed but in 13.5 fails. Our investigation shown that in both Feign versions IOException is thrown but in 13.1 it's correctly caught in SynchronousMethodHandler.executeAndDecode:

java.io.IOException: chunked transfer encoding, state: READING_LENGTH

And in 13.5 it's not caught. The last line that was executed is

cf = sendAsync(req, responseHandler, null, null);

in HttpClientImpl.send

@sergey-morenets
Copy link
Author

Our deeper analysis shown that this regression appeared in 13.3 and possible reason is the replacement

httpResponse = clientForRequest.send(httpRequest, BodyHandlers.ofByteArray());

with

httpResponse = clientForRequest.send(httpRequest, BodyHandlers.ofInputStream());

in Http2Client.

@sergey-morenets
Copy link
Author

So IOException actually happens then we try to read response body (in IOUtils.toString):

var response = cityClient.create(city);
var body = IOUtils.toString(response.body().asInputStream(), Charset.defaultCharset());

And main issue is that this exception occurs outside of Feign client and that means retry logic would not be executed.

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

No branches or pull requests

1 participant