From 18e9d5df4f02db6c9347dfd94f92e94f7a47fcd4 Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Mon, 15 Jan 2024 16:49:17 +0800 Subject: [PATCH] fix:fix reporter wrong initialization when using config data. (#1221) --- CHANGELOG.md | 1 + .../config/configdata/PolarisConfigDataLocationResolver.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e040a4109..eb0e6b470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ - [feat:optimize examples.](https://github.com/Tencent/spring-cloud-tencent/pull/1185) - [fix:fix rule-based router when using RestTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/1200) - [fix:fix sct-all wrong spring boot version obtain.](https://github.com/Tencent/spring-cloud-tencent/pull/1203) +- [fix:fix reporter wrong initialization when using config data.](https://github.com/Tencent/spring-cloud-tencent/pull/1221) diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/configdata/PolarisConfigDataLocationResolver.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/configdata/PolarisConfigDataLocationResolver.java index f55d0261c..a79f713ae 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/configdata/PolarisConfigDataLocationResolver.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/configdata/PolarisConfigDataLocationResolver.java @@ -31,6 +31,7 @@ import com.tencent.cloud.polaris.context.config.PolarisContextProperties; import com.tencent.polaris.api.utils.StringUtils; import com.tencent.polaris.client.api.SDKContext; +import com.tencent.polaris.factory.config.ConfigurationImpl; import org.apache.commons.logging.Log; import org.springframework.boot.BootstrapRegistry; @@ -267,6 +268,10 @@ private void prepareAndInitEarlierPolarisSdkContext(ConfigDataLocationResolverCo if (!bootstrapContext.isRegistered(SDKContext.class)) { SDKContext sdkContext = sdkContext(resolverContext, polarisConfigProperties, polarisCryptoConfigProperties, polarisContextProperties); + // not init reporter when creating config data temp SDK context. + if (sdkContext.getConfig() instanceof ConfigurationImpl) { + ((ConfigurationImpl) sdkContext.getConfig()).getGlobal().getStatReporter().setEnable(false); + } sdkContext.init(); bootstrapContext.register(SDKContext.class, BootstrapRegistry.InstanceSupplier.of(sdkContext)); }