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

Fix WebClient Memory Leaks #7293

Closed
rwinch opened this issue Aug 21, 2019 · 0 comments

Comments

@rwinch
Copy link
Member

commented Aug 21, 2019

Summary

The documentation states:

When you use exchange(), you must always use any of the body or toEntity methods of ClientResponse to ensure resources are released and to avoid potential issues with HTTP connection pooling. You can use bodyToMono(Void.class) if no response content is expected. However, if the response does have content, the connection is closed and is not placed back in the pool.

There are multiple places where the status is looked at and if it isn't 2xx then it throws an exception without consuming the body which causes a leak.

@rwinch rwinch self-assigned this Aug 21, 2019

@rwinch rwinch added this to the 5.2.0.RC1 milestone Aug 21, 2019

@rwinch rwinch closed this in a377581 Aug 21, 2019

rwinch added a commit that referenced this issue Aug 21, 2019
Fix WebClient Memory Leaks
WebClient exchange requires that the body is consumed. Before this commit
there were places where an Exception was thrown without consuming the body
if the status was not successful. There was also the potential for the
statusCode invocation to throw an Exception of the status code was not
defined which would cause a leak.

This commit ensures that before the Exception is thrown the body is
consumed. It also uses the http status in a way that will ensure an
Exception is not thrown.

Fixes gh-7293
kostya05983 added a commit to kostya05983/spring-security that referenced this issue Aug 26, 2019
Fix WebClient Memory Leaks
WebClient exchange requires that the body is consumed. Before this commit
there were places where an Exception was thrown without consuming the body
if the status was not successful. There was also the potential for the
statusCode invocation to throw an Exception of the status code was not
defined which would cause a leak.

This commit ensures that before the Exception is thrown the body is
consumed. It also uses the http status in a way that will ensure an
Exception is not thrown.

Fixes spring-projectsgh-7293
fhanik added a commit to fhanik/spring-security that referenced this issue Aug 27, 2019
Fix WebClient Memory Leaks
WebClient exchange requires that the body is consumed. Before this commit
there were places where an Exception was thrown without consuming the body
if the status was not successful. There was also the potential for the
statusCode invocation to throw an Exception of the status code was not
defined which would cause a leak.

This commit ensures that before the Exception is thrown the body is
consumed. It also uses the http status in a way that will ensure an
Exception is not thrown.

Fixes spring-projectsgh-7293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.