From cc927d611a95b9b4fa0ee6329478faa3fa5c2388 Mon Sep 17 00:00:00 2001 From: Fishtail <49390359+fuyuwei01@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:46:09 +0800 Subject: [PATCH] fix:fix contract reporting bug when using TSF. (#1422) Co-authored-by: Haotian Zhang --- CHANGELOG.md | 1 + .../polaris/contract/config/PolarisContractProperties.java | 6 ------ .../cloud/polaris/contract/tsf/TsfContractProperties.java | 2 +- .../context/tsf/env/TsfCoreEnvironmentPostProcessor.java | 1 + 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a139d383..3b6df3ddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,4 @@ - [feat: support otel trace](https://github.com/Tencent/spring-cloud-tencent/pull/1419) - [feat:support TSF router.](https://github.com/Tencent/spring-cloud-tencent/pull/1420) - [feat:upgrade nearby router and add namespace nearby router.](https://github.com/Tencent/spring-cloud-tencent/pull/1421) +- [fix:fix contract reporting bug when using TSF.](https://github.com/Tencent/spring-cloud-tencent/pull/1422) diff --git a/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/config/PolarisContractProperties.java b/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/config/PolarisContractProperties.java index 3f698288d..b297fb0d0 100644 --- a/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/config/PolarisContractProperties.java +++ b/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/config/PolarisContractProperties.java @@ -161,17 +161,11 @@ public class PolarisContractProperties implements ContractProperties { @Override public boolean isReportEnabled() { - if (Objects.nonNull(extendContractProperties)) { - return extendContractProperties.isReportEnabled(); - } return reportEnabled; } @Override public void setReportEnabled(boolean reportEnabled) { - if (Objects.nonNull(extendContractProperties)) { - extendContractProperties.setReportEnabled(reportEnabled); - } this.reportEnabled = reportEnabled; } diff --git a/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/tsf/TsfContractProperties.java b/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/tsf/TsfContractProperties.java index 997bfbc1d..64cd71051 100644 --- a/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/tsf/TsfContractProperties.java +++ b/spring-cloud-starter-tencent-polaris-contract/src/main/java/com/tencent/cloud/polaris/contract/tsf/TsfContractProperties.java @@ -56,7 +56,7 @@ public class TsfContractProperties implements ExtendedContractProperties { @Override public boolean isEnabled() { - return false; + return enabled; } @Override diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java index fd39beb9b..135f5d9f7 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/tsf/env/TsfCoreEnvironmentPostProcessor.java @@ -105,6 +105,7 @@ public final class TsfCoreEnvironmentPostProcessor implements EnvironmentPostPro defaultProperties.put("spring.cloud.polaris.config.enabled", "true"); } else { + defaultProperties.put("spring.cloud.polaris.contract.report.enabled", "false"); defaultProperties.put("spring.cloud.polaris.config.enabled", "true"); defaultProperties.put("spring.cloud.polaris.config.internal-enabled", "false"); defaultProperties.put("spring.cloud.polaris.config.data-source", "consul");