From bc964da64f06ba3fd7e8e50d16f61ace6e021d03 Mon Sep 17 00:00:00 2001 From: chengyouling Date: Wed, 15 Jan 2025 09:49:02 +0800 Subject: [PATCH] [#4676] optimized the method of building ServiceCenterClient --- .../service/center/client/ServiceCenterClient.java | 5 +++-- .../org/apache/servicecomb/registry/sc/SCClientUtils.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clients/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterClient.java b/clients/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterClient.java index 45c4c27dc01..a238d118d2d 100755 --- a/clients/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterClient.java +++ b/clients/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterClient.java @@ -69,10 +69,11 @@ public class ServiceCenterClient implements ServiceCenterOperation { private EventBus eventBus; - private ServiceCenterAddressManager addressManager; + private final ServiceCenterAddressManager addressManager; - public ServiceCenterClient(ServiceCenterRawClient httpClient) { + public ServiceCenterClient(ServiceCenterRawClient httpClient, ServiceCenterAddressManager addressManager) { this.httpClient = httpClient; + this.addressManager = addressManager; } public ServiceCenterClient setEventBus(EventBus eventBus) { diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/registry/sc/SCClientUtils.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/registry/sc/SCClientUtils.java index b248f467610..4d29de05a2c 100644 --- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/registry/sc/SCClientUtils.java +++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/registry/sc/SCClientUtils.java @@ -66,7 +66,7 @@ public static ServiceCenterClient serviceCenterClient(SCConfigurationProperties return new ServiceCenterClient(new ServiceCenterRawClient.Builder() .setTenantName("default") .setAddressManager(addressManager) - .setHttpTransport(createHttpTransport(environment, sslProperties)).build()); + .setHttpTransport(createHttpTransport(environment, sslProperties)).build(), addressManager); } private static HttpTransport createHttpTransport(Environment environment, SSLProperties sslProperties) {