From 82e83a27a1ba26fc3a13fc700a159606826ab1fb Mon Sep 17 00:00:00 2001 From: mstrankowski Date: Fri, 22 Sep 2023 14:54:39 +0200 Subject: [PATCH] Change to Poolable connection manager, due to RestTemplate provided for mTLS being a singleton - possible reuse of connections or multithreaded usage --- .../main/java/org/alfresco/transformer/config/MTLSConfig.java | 4 ++-- .../java/org/alfresco/transform/base/config/MTLSConfig.java | 4 ++-- .../test/java/org/alfresco/transform/base/MtlsTestUtils.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deprecated/alfresco-transformer-base/src/main/java/org/alfresco/transformer/config/MTLSConfig.java b/deprecated/alfresco-transformer-base/src/main/java/org/alfresco/transformer/config/MTLSConfig.java index a69258d83..17fae4755 100644 --- a/deprecated/alfresco-transformer-base/src/main/java/org/alfresco/transformer/config/MTLSConfig.java +++ b/deprecated/alfresco-transformer-base/src/main/java/org/alfresco/transformer/config/MTLSConfig.java @@ -29,7 +29,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.socket.ConnectionSocketFactory; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; @@ -139,7 +139,7 @@ RegistryBuilder. create() .register("https", sslConnectionSocketFactory) .build(); - final BasicHttpClientConnectionManager sslConnectionManager = new BasicHttpClientConnectionManager(sslSocketFactoryRegistry); + final PoolingHttpClientConnectionManager sslConnectionManager = new PoolingHttpClientConnectionManager(sslSocketFactoryRegistry); HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(sslConnectionManager); CloseableHttpClient httpClient = httpClientBuilder.build(); diff --git a/engines/base/src/main/java/org/alfresco/transform/base/config/MTLSConfig.java b/engines/base/src/main/java/org/alfresco/transform/base/config/MTLSConfig.java index d8be89c53..4b6a12e3e 100644 --- a/engines/base/src/main/java/org/alfresco/transform/base/config/MTLSConfig.java +++ b/engines/base/src/main/java/org/alfresco/transform/base/config/MTLSConfig.java @@ -32,7 +32,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.socket.ConnectionSocketFactory; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; @@ -198,7 +198,7 @@ RegistryBuilder. create() .register("https", sslConnectionSocketFactory) .build(); - final BasicHttpClientConnectionManager sslConnectionManager = new BasicHttpClientConnectionManager(sslSocketFactoryRegistry); + final PoolingHttpClientConnectionManager sslConnectionManager = new PoolingHttpClientConnectionManager(sslSocketFactoryRegistry); HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(sslConnectionManager); CloseableHttpClient httpClient = httpClientBuilder.build(); diff --git a/engines/base/src/test/java/org/alfresco/transform/base/MtlsTestUtils.java b/engines/base/src/test/java/org/alfresco/transform/base/MtlsTestUtils.java index 95e797b71..ff4fd2200 100644 --- a/engines/base/src/test/java/org/alfresco/transform/base/MtlsTestUtils.java +++ b/engines/base/src/test/java/org/alfresco/transform/base/MtlsTestUtils.java @@ -28,7 +28,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.io.HttpClientConnectionManager; import org.apache.hc.client5.http.socket.ConnectionSocketFactory; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; @@ -111,7 +111,7 @@ RegistryBuilder. create() .register("https", sslConnectionSocketFactory) .build(); - return new BasicHttpClientConnectionManager(sslSocketFactoryRegistry); + return new PoolingHttpClientConnectionManager(sslSocketFactoryRegistry); } public static RestTemplate restTemplateWithMtls()