-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
See #29370 for context
Background:
We declaratively create RestClients during start-up based on the configurations. We keep track of the created clients and need to refresh the client (basically create a fresh one) on refresh (config changes, certificate changes, etc.). When doing so, we were not able to properly clean up the resources associated with the existing client (like connection pools, etc) because ClientHttpRequestFactory does not support it by default. We are worried about the resource leaks due to referencing clients without closing them properly.
The current workaround we use is to rely on implementations of ClientHttpRequestFactory. Some of them do implement AutoClosable/DisposableBean/Lifecycle, and we use this to close the resource, but implementations like JdkClientHttpRequestFactory do not implement any of these.
It would be great if ClientHttpRequestFactory implements AutoCloseable to support resource clean-up. #29370 attempted to fix this, but got reverted due to some other issues with RestTemplate. It would be great to revisit this and, in the worst case, make the implementations extend a consistent interface to support clean-ups.