提交 05eca056 编写于 作者: B Brian Clozel

Close resources in HttpComponents client connector

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 gh-27032
上级 3fa4e416
......@@ -16,6 +16,8 @@
package org.springframework.http.client.reactive;
import java.io.Closeable;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.function.BiFunction;
......@@ -48,7 +50,7 @@ import org.springframework.util.Assert;
* @since 5.3
* @see <a href="https://hc.apache.org/index.html">Apache HttpComponents</a>
*/
public class HttpComponentsClientHttpConnector implements ClientHttpConnector {
public class HttpComponentsClientHttpConnector implements ClientHttpConnector, Closeable {
private final CloseableHttpAsyncClient client;
......@@ -126,6 +128,10 @@ public class HttpComponentsClientHttpConnector implements ClientHttpConnector {
});
}
@Override
public void close() throws IOException {
this.client.close();
}
private static class MonoFutureCallbackAdapter
implements FutureCallback<Message<HttpResponse, Publisher<ByteBuffer>>> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册