From cd2a9918be880093f24463023e03bceeaf5c5037 Mon Sep 17 00:00:00 2001 From: inthirakumaaran Date: Thu, 25 Sep 2025 17:56:31 +0530 Subject: [PATCH 1/3] Create new http client manager. --- .../identity/core/HTTPClientManager.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java new file mode 100644 index 000000000000..08772018bc0f --- /dev/null +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.utils.HTTPClientUtils; + +/** + * Manage HTTP client creation with pool. + */ +public class HTTPClientManager { + + public static final String HTTP_CLIENT_MAX_TOTAL_CONNECTIONS = "HttpClient.ConnectionPool.MaxTotalConnections"; + public static final String HTTP_CLIENT_DEFAULT_MAX_CONNECTIONS_PER_ROUTE = + "HttpClient.ConnectionPool.DefaultMaxConnectionsPerRoute"; + public static final String HTTP_CLIENT_ADD_KEEP_ALIVE_STRATEGY = + "HttpClient.ConnectionPool.AddKeepAliveStrategy"; + + private static final Log log = LogFactory.getLog(HTTPClientManager.class); + private static final CloseableHttpClient httpClient; + private static final String CLIENT = "Client "; + + private HTTPClientManager() { + } + + static { + + String maxTotalConnectionProp = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_MAX_TOTAL_CONNECTIONS); + String defaultMaxPerRouteProp = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_DEFAULT_MAX_CONNECTIONS_PER_ROUTE); + String addKeepAliveStrategy = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_ADD_KEEP_ALIVE_STRATEGY); + + int maxTotalConnections = 100; + int defaultMaxPerRoute = 100; + + if (maxTotalConnectionProp != null) { + try { + maxTotalConnections = Integer.parseInt(maxTotalConnectionProp); + } catch (NumberFormatException ignore) { + log.debug("Parsing issue for maxTotalConnections property: " + maxTotalConnectionProp); + } + } + if (defaultMaxPerRouteProp != null) { + try { + maxTotalConnections = Integer.parseInt(defaultMaxPerRouteProp); + } catch (NumberFormatException ignore) { + log.debug("Parsing issue for defaultMaxPerRoute property: " + defaultMaxPerRouteProp); + } + } + + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); + connManager.setMaxTotal(maxTotalConnections); + connManager.setDefaultMaxPerRoute(defaultMaxPerRoute); + + HttpClientBuilder clientBuilder = HTTPClientUtils.createClientWithCustomVerifier(); + clientBuilder.setConnectionManager(connManager); + if (Boolean.parseBoolean(addKeepAliveStrategy)) { + clientBuilder.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()); + } + httpClient = clientBuilder.build(); + } + + public static CloseableHttpClient getHttpClient() { + + return httpClient; + } +} From 8e79381f6f59b3f46737540e54c2d07955a0cfce Mon Sep 17 00:00:00 2001 From: inthirakumaaran Date: Mon, 13 Oct 2025 17:40:59 +0530 Subject: [PATCH 2/3] Configure connection pooling. --- .../util/AuthenticationEndpointUtil.java | 9 +- .../util/client/AuthAPIServiceClient.java | 9 +- .../identity/core/HTTPClientManager.java | 136 +++++++++++++----- .../util/IdentityManagementEndpointUtil.java | 10 +- .../client/PreferenceRetrievalClient.java | 2 +- .../client/SelfRegistrationMgtClient.java | 11 +- 6 files changed, 136 insertions(+), 41 deletions(-) diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java index 92152e42f1fe..efa42359280c 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/AuthenticationEndpointUtil.java @@ -36,6 +36,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.application.authentication.endpoint.util.bean.UserDTO; import org.wso2.carbon.identity.application.authentication.framework.config.ConfigurationFacade; +import org.wso2.carbon.identity.core.HTTPClientManager; import org.wso2.carbon.identity.core.ServiceURLBuilder; import org.wso2.carbon.identity.core.URLBuilderException; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; @@ -375,11 +376,15 @@ private static String buildAbsoluteURL(String contextPath) throws URLBuilderExce */ public static String sendGetRequest(String backendURL) { - try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) { + return HTTPClientManager.executeWithHttpClient(httpClient -> + sendGetRequest(backendURL, httpClient)); + } + + private static String sendGetRequest(String backendURL, CloseableHttpClient httpclient) { + try { HttpGet httpGet = new HttpGet(backendURL); setAuthorizationHeader(httpGet); - return httpclient.execute(httpGet, response -> { if (log.isDebugEnabled()) { log.debug("HTTP status " + response.getCode() + diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java index 680c6b0e2dd4..f4d58eeb1858 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/src/main/java/org/wso2/carbon/identity/application/authentication/endpoint/util/client/AuthAPIServiceClient.java @@ -30,6 +30,7 @@ import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationErrorResponse; import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationResponse; import org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationSuccessResponse; +import org.wso2.carbon.identity.core.HTTPClientManager; import org.wso2.carbon.utils.httpclient5.HTTPClientUtils; import java.io.BufferedReader; @@ -81,8 +82,14 @@ public AuthenticationResponse authenticate(String username, Object password) thr HttpPost httpPostRequest = new HttpPost(endpointURL); httpPostRequest.setHeader(HttpHeaders.AUTHORIZATION, buildBasicAuthHeader(username, password)); httpPostRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + return HTTPClientManager.executeWithHttpClient(httpClient -> + authenticate(httpClient, httpPostRequest, endpointURL)); + } + + private AuthenticationResponse authenticate(CloseableHttpClient httpClient, HttpPost httpPostRequest, + String endpointURL) throws ServiceClientException { - try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) { + try { return httpClient.execute(httpPostRequest, response -> { String responseString; diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java index 08772018bc0f..fd046bc42159 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java @@ -20,12 +20,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.DefaultConnectionKeepAliveStrategy; +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.io.PoolingHttpClientConnectionManager; import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.utils.HTTPClientUtils; +import org.wso2.carbon.utils.httpclient5.HTTPClientUtils; + +import java.io.IOException; /** * Manage HTTP client creation with pool. @@ -37,55 +39,119 @@ public class HTTPClientManager { "HttpClient.ConnectionPool.DefaultMaxConnectionsPerRoute"; public static final String HTTP_CLIENT_ADD_KEEP_ALIVE_STRATEGY = "HttpClient.ConnectionPool.AddKeepAliveStrategy"; + public static final String HTTP_CLIENT_POOL_ENABLED = "HttpClient.ConnectionPool.Enabled"; private static final Log log = LogFactory.getLog(HTTPClientManager.class); private static final CloseableHttpClient httpClient; - private static final String CLIENT = "Client "; + private static final boolean isConnectionPoolEnabled; private HTTPClientManager() { } static { - String maxTotalConnectionProp = ServerConfiguration.getInstance() - .getFirstProperty(HTTP_CLIENT_MAX_TOTAL_CONNECTIONS); - String defaultMaxPerRouteProp = ServerConfiguration.getInstance() - .getFirstProperty(HTTP_CLIENT_DEFAULT_MAX_CONNECTIONS_PER_ROUTE); - String addKeepAliveStrategy = ServerConfiguration.getInstance() - .getFirstProperty(HTTP_CLIENT_ADD_KEEP_ALIVE_STRATEGY); + isConnectionPoolEnabled = Boolean.parseBoolean( + ServerConfiguration.getInstance().getFirstProperty(HTTP_CLIENT_POOL_ENABLED)); - int maxTotalConnections = 100; - int defaultMaxPerRoute = 100; + HttpClientBuilder clientBuilder = HTTPClientUtils.createClientWithCustomHostnameVerifier(); - if (maxTotalConnectionProp != null) { - try { - maxTotalConnections = Integer.parseInt(maxTotalConnectionProp); - } catch (NumberFormatException ignore) { - log.debug("Parsing issue for maxTotalConnections property: " + maxTotalConnectionProp); + if (isConnectionPoolEnabled) { + + String maxTotalConnectionProp = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_MAX_TOTAL_CONNECTIONS); + String defaultMaxPerRouteProp = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_DEFAULT_MAX_CONNECTIONS_PER_ROUTE); + String addKeepAliveStrategy = ServerConfiguration.getInstance() + .getFirstProperty(HTTP_CLIENT_ADD_KEEP_ALIVE_STRATEGY); + + int maxTotalConnections = 100; + int defaultMaxPerRoute = 100; + + if (maxTotalConnectionProp != null) { + try { + maxTotalConnections = Integer.parseInt(maxTotalConnectionProp); + } catch (NumberFormatException ignore) { + log.debug("Parsing issue for maxTotalConnections property: " + maxTotalConnectionProp); + } + } + if (defaultMaxPerRouteProp != null) { + try { + defaultMaxPerRoute = Integer.parseInt(defaultMaxPerRouteProp); + } catch (NumberFormatException ignore) { + log.debug("Parsing issue for defaultMaxPerRoute property: " + defaultMaxPerRouteProp); + } + } + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); + connManager.setMaxTotal(maxTotalConnections); + connManager.setDefaultMaxPerRoute(defaultMaxPerRoute); + clientBuilder.setConnectionManager(connManager); + if (Boolean.parseBoolean(addKeepAliveStrategy)) { + clientBuilder.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()); } } - if (defaultMaxPerRouteProp != null) { + httpClient = clientBuilder.build(); + } + + public static CloseableHttpClient getHttpClient() { + + return httpClient; + } + + /** + * Executes an operation with appropriate HttpClient management. + * Handles both pooled and non-pooled clients, ensuring proper cleanup. + * + * @param operation The operation to execute with the HttpClient + * @param Return type of the operation + * @param Exception type that the operation may throw + * @return Result of the operation + * @throws E if operation fails + */ + public static T executeWithHttpClient(HttpClientOperation operation) + throws E { + + boolean usePooling = isConnectionPoolEnabled; + CloseableHttpClient httpClient = usePooling ? getHttpClient() + : HTTPClientUtils.createClientWithCustomHostnameVerifier().build(); + + try { + return operation.execute(httpClient); + } finally { + closeHttpClientIfNeeded(httpClient); + } + } + + /** + * Closes HttpClient only if not using connection pooling. + * + * @param httpClient The client to close + */ + private static void closeHttpClientIfNeeded(CloseableHttpClient httpClient) { + + if (!isConnectionPoolEnabled) { try { - maxTotalConnections = Integer.parseInt(defaultMaxPerRouteProp); - } catch (NumberFormatException ignore) { - log.debug("Parsing issue for defaultMaxPerRoute property: " + defaultMaxPerRouteProp); + httpClient.close(); + } catch (IOException e) { + log.debug("Failed to close non-pooled HttpClient", e); } } + } - PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); - connManager.setMaxTotal(maxTotalConnections); - connManager.setDefaultMaxPerRoute(defaultMaxPerRoute); + public static boolean isConnectionPoolEnabled() { - HttpClientBuilder clientBuilder = HTTPClientUtils.createClientWithCustomVerifier(); - clientBuilder.setConnectionManager(connManager); - if (Boolean.parseBoolean(addKeepAliveStrategy)) { - clientBuilder.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()); - } - httpClient = clientBuilder.build(); + return isConnectionPoolEnabled; } - public static CloseableHttpClient getHttpClient() { + /** + * Functional interface for operations that use HttpClient. + * Generalized to work with any exception type. + * + * @param Return type of the operation + * @param Exception type that may be thrown + */ + @FunctionalInterface + public interface HttpClientOperation { - return httpClient; + T execute(CloseableHttpClient httpClient) throws E; } -} +} \ No newline at end of file diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java index 625fa1412f30..91cea3ed6876 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java @@ -43,6 +43,7 @@ import org.wso2.carbon.core.SameSiteCookie; import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants; import org.wso2.carbon.identity.base.IdentityRuntimeException; +import org.wso2.carbon.identity.core.HTTPClientManager; import org.wso2.carbon.identity.core.ServiceURLBuilder; import org.wso2.carbon.identity.core.URLBuilderException; import org.wso2.carbon.identity.core.model.CookieBuilder; @@ -1049,7 +1050,10 @@ private static void updateCookieConfig(CookieBuilder cookieBuilder, IdentityCook */ public static String getHttpClientResponseString(HttpUriRequestBase request) throws IOException { - try (CloseableHttpClient httpClient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) { + CloseableHttpClient httpClient = HTTPClientManager.isConnectionPoolEnabled() ? + HTTPClientManager.getHttpClient() : + HTTPClientUtils.createClientWithCustomHostnameVerifier().build(); + try { return httpClient.execute(request, response -> { if (response.getCode() == HttpStatus.SC_OK) { try (InputStream inputStream = response.getEntity().getContent(); @@ -1066,6 +1070,10 @@ public static String getHttpClientResponseString(HttpUriRequestBase request) thr } return null; }); + } finally { + if (!HTTPClientManager.isConnectionPoolEnabled()) { + httpClient.close(); + } } } } diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java index e2dfe93fc6bc..addf93af98c1 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/PreferenceRetrievalClient.java @@ -522,7 +522,7 @@ public boolean checkPreference(String tenant, String connectorName, String prope public boolean checkMultiplePreference(String tenant, String connectorName, List propertyNames) throws PreferenceRetrievalClientException { - try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) { + try { JSONArray requestBody = new JSONArray(); JSONObject preference = new JSONObject(); preference.put(CONNECTOR_NAME, connectorName); diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java index c278fbe55e5b..b32c475089f6 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/client/SelfRegistrationMgtClient.java @@ -35,6 +35,7 @@ import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener; +import org.wso2.carbon.identity.core.HTTPClientManager; import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointConstants; import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil; import org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementServiceUtil; @@ -229,12 +230,20 @@ public JSONObject checkUsernameValidityStatus(User user, boolean skipSignUpCheck private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCheck) throws SelfRegistrationMgtClientException { + return HTTPClientManager.executeWithHttpClient(httpClient -> + checkUserNameValidityInternal(user, skipSignUpCheck, httpClient)); + } + + private JSONObject checkUserNameValidityInternal(User user, boolean skipSignUpCheck, + CloseableHttpClient httpclient) + throws SelfRegistrationMgtClientException { + if (log.isDebugEnabled()) { log.debug("Checking username validating for username: " + user.getUsername() + ". SkipSignUpCheck flag is set to " + skipSignUpCheck); } - try (CloseableHttpClient httpclient = HTTPClientUtils.createClientWithCustomHostnameVerifier().build()) { + try { JSONObject userObject = new JSONObject(); userObject.put(USERNAME, user.getUsername()); From ae2de2523b5835a2a0fade826a23a58defea05e7 Mon Sep 17 00:00:00 2001 From: inthirakumaaran Date: Wed, 15 Oct 2025 14:18:23 +0530 Subject: [PATCH 3/3] Add debug logs for http connection pool. --- .../java/org/wso2/carbon/identity/core/HTTPClientManager.java | 3 +++ .../mgt/endpoint/util/IdentityManagementEndpointUtil.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java index fd046bc42159..5d2a98b1a706 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/HTTPClientManager.java @@ -55,6 +55,9 @@ private HTTPClientManager() { HttpClientBuilder clientBuilder = HTTPClientUtils.createClientWithCustomHostnameVerifier(); + if (log.isDebugEnabled()) { + log.debug("Initializing HTTPClientManager with connection pool enabled: " + isConnectionPoolEnabled); + } if (isConnectionPoolEnabled) { String maxTotalConnectionProp = ServerConfiguration.getInstance() diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java index 91cea3ed6876..f33fd706af9d 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/src/main/java/org/wso2/carbon/identity/mgt/endpoint/util/IdentityManagementEndpointUtil.java @@ -1053,6 +1053,10 @@ public static String getHttpClientResponseString(HttpUriRequestBase request) thr CloseableHttpClient httpClient = HTTPClientManager.isConnectionPoolEnabled() ? HTTPClientManager.getHttpClient() : HTTPClientUtils.createClientWithCustomHostnameVerifier().build(); + if (log.isDebugEnabled()) { + log.debug("Using " + (HTTPClientManager.isConnectionPoolEnabled() ? "pooled" : "new") + + " HTTP client for request: " + request.getMethod() + " " + request.getPath()); + } try { return httpClient.execute(request, response -> { if (response.getCode() == HttpStatus.SC_OK) {