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

Connection pool leak in spring-cloud-gateway-server-mvc when retrying with Apache HTTP client #3696

Open
johan1a opened this issue Feb 14, 2025 · 0 comments

Comments

@johan1a
Copy link

johan1a commented Feb 14, 2025

Describe the bug
I suspect that leased connections are not released back into the connection pool when an error is encountered, and the Apache HTTP client is used in combination with the retry filter. I think it is because the response body is not read before throwing a RetryException.

It seems that if something like the following is added to RetryFilterFunctions, right before this line of code, the connections get released back again:

        InputStream responseInputStream = MvcUtils.getAttribute(request, MvcUtils.CLIENT_RESPONSE_INPUT_STREAM_ATTR);
        StreamUtils.copy(responseInputStream, OutputStream.nullOutputStream());

Sample
Here is a repo that reproduces the issue: https://github.com/johan1a/spring-cloud-gateway-mvc-connection-test/tree/master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant