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

HttpComponentsClientHttpConnector should close underlying resources #27032

Closed
bclozel opened this issue Jun 7, 2021 · 1 comment
Closed

HttpComponentsClientHttpConnector should close underlying resources #27032

bclozel opened this issue Jun 7, 2021 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Jun 7, 2021

As seen in spring-projects/spring-boot#26214 (comment), the HttpComponentsClientHttpConnector can be instantiated with a custom client instance or create a default one. The connector implementation doesn't provide access to the underlying client nor implements the Closeableinterface.

We should ensure that the connector can close the resources it's using. This should not be done through the WebClient interface since client resources can be shared amongst clients or even with the server.

In the case of the HttpComponentsClientHttpConnector in Spring Boot, it is created as a Spring bean and will be considered when components are shut down.

@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Jun 7, 2021
@bclozel bclozel added this to the 5.3.8 milestone Jun 7, 2021
@bclozel bclozel self-assigned this Jun 7, 2021
@bclozel bclozel closed this as completed in 05eca05 Jun 8, 2021
@JanHron
Copy link

JanHron commented Sep 6, 2021

@bclozel I realized I never thanked you for the quick fix of this. It actually solved our problem back then; if we ever meet on a conference or something, I'll treat you to a beer or another tasty beverage of your choice ;-)

lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Prior to this commit, the `HttpComponentsClientHttpConnector`
implementation could accept or create a default `HttpClient` instance
but not expose it as part of its API. This effectively prevents
applications from properly closing the associated resources when
disposing of the connector.

This commit implements the `Closeable` interface on the connector to
allow this use case.

Closes spring-projectsgh-27032
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants