From ca37c4f07b12309a0bbd6562e66f41a7d6984a02 Mon Sep 17 00:00:00 2001 From: Arjan Bal Date: Mon, 18 Dec 2023 17:57:49 +0530 Subject: [PATCH] Use internal router for creating remote clients when configured and using alternate factory method --- .../internal/remote/RemoteClientFactory.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cdap-common/src/main/java/io/cdap/cdap/common/internal/remote/RemoteClientFactory.java b/cdap-common/src/main/java/io/cdap/cdap/common/internal/remote/RemoteClientFactory.java index cac10af297ef..16fa73230dd6 100644 --- a/cdap-common/src/main/java/io/cdap/cdap/common/internal/remote/RemoteClientFactory.java +++ b/cdap-common/src/main/java/io/cdap/cdap/common/internal/remote/RemoteClientFactory.java @@ -117,15 +117,8 @@ public RemoteClientFactory(DiscoveryServiceClient discoveryClient, */ public RemoteClient createRemoteClient(String discoverableServiceName, HttpRequestConfig httpRequestConfig, String basePath) { - basePath = basePath.startsWith("/") ? pathPrefix + basePath - : pathPrefix + "/" + basePath; - if (this.internalRouterEnabled) { - return getClientForInternalRouter(discoverableServiceName, - httpRequestConfig, basePath); - } - return new RemoteClient(internalAuthenticator, discoveryClient, - discoverableServiceName, httpRequestConfig, basePath, - remoteAuthenticator); + return createRemoteClient(discoverableServiceName, httpRequestConfig, + basePath, internalAuthenticator); } /** @@ -143,12 +136,18 @@ public RemoteClient createRemoteClient(String discoverableServiceName, HttpRequestConfig httpRequestConfig, String basePath, InternalAuthenticator internalAuthenticator) { basePath = basePath.startsWith("/") ? pathPrefix + basePath : pathPrefix + "/" + basePath; - return new RemoteClient(internalAuthenticator, discoveryClient, discoverableServiceName, + if (this.internalRouterEnabled) { + return getClientForInternalRouter(discoverableServiceName, + httpRequestConfig, basePath, internalAuthenticator); + } + return new RemoteClient(internalAuthenticator, discoveryClient, + discoverableServiceName, httpRequestConfig, basePath, remoteAuthenticator); } private RemoteClient getClientForInternalRouter(String destinationServiceName, - HttpRequestConfig httpRequestConfig, String basePath) { + HttpRequestConfig httpRequestConfig, String basePath, + InternalAuthenticator internalAuthenticator) { LOG.trace( "Creating client for service '{}' which routes through service '{}'.", destinationServiceName, Service.INTERNAL_ROUTER);