From b3feb94b73ae13ebbfb854cd8a541e3cd9881600 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Fri, 6 Jan 2023 16:56:09 +0800 Subject: [PATCH] fix:fix nacos enabled condition bugs. (#794) --- CHANGELOG.md | 1 + .../discovery/DiscoveryEnabledCondition.java | 16 +++++++++++----- .../registry/RegisterEnabledCondition.java | 9 +++++++++ spring-cloud-tencent-dependencies/pom.xml | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87936125b..20ff1fd6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ - [Bugfix: fix reactor concurrent bug when get instances & fix spring-retry fuse not working bug](https://github.com/Tencent/spring-cloud-tencent/pull/775) - [Fix issue: prompt no registration if web dependence was not imported.](https://github.com/Tencent/spring-cloud-tencent/pull/777) - [set reporter.enabled default to true](https://github.com/Tencent/spring-cloud-tencent/pull/786) +- [fix:fix nacos enabled condition bugs.](https://github.com/Tencent/spring-cloud-tencent/pull/794) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/DiscoveryEnabledCondition.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/DiscoveryEnabledCondition.java index f63959187..ae9447cfa 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/DiscoveryEnabledCondition.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/DiscoveryEnabledCondition.java @@ -36,12 +36,18 @@ public class DiscoveryEnabledCondition implements Condition { boolean isConsulDiscoveryEnabled = Boolean.parseBoolean( conditionContext.getEnvironment().getProperty("spring.cloud.consul.enabled", "false")) - && Boolean.parseBoolean(conditionContext.getEnvironment() - .getProperty("spring.cloud.consul.discovery.enabled", "true")); + && Boolean.parseBoolean( + conditionContext.getEnvironment().getProperty("spring.cloud.consul.discovery.enabled", "true")); - boolean isNacosEnabled = Boolean.parseBoolean( - conditionContext.getEnvironment().getProperty("spring.cloud.nacos.discovery.enabled", "false")); + isDiscoveryEnabled |= isConsulDiscoveryEnabled; - return isDiscoveryEnabled || isConsulDiscoveryEnabled || isNacosEnabled; + boolean isNacosDiscoveryEnabled = Boolean.parseBoolean( + conditionContext.getEnvironment().getProperty("spring.cloud.nacos.enabled", "false")) + && Boolean.parseBoolean( + conditionContext.getEnvironment().getProperty("spring.cloud.nacos.discovery.enabled", "true")); + + isDiscoveryEnabled |= isNacosDiscoveryEnabled; + + return isDiscoveryEnabled; } } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/RegisterEnabledCondition.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/RegisterEnabledCondition.java index 74c57edd4..310110d42 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/RegisterEnabledCondition.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/RegisterEnabledCondition.java @@ -39,6 +39,15 @@ public class RegisterEnabledCondition implements Condition { .getProperty("spring.cloud.consul.discovery.register", "true")); isRegisterEnabled |= isConsulRegisterEnabled; + + boolean isNacosRegisterEnabled = Boolean + .parseBoolean(conditionContext.getEnvironment() + .getProperty("spring.cloud.nacos.enabled", "false")) + && Boolean.parseBoolean(conditionContext.getEnvironment() + .getProperty("spring.cloud.nacos.discovery.register-enabled", "true")); + + isRegisterEnabled |= isNacosRegisterEnabled; + return isRegisterEnabled; } } diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index f746931c4..dc80a0f8d 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -73,7 +73,7 @@ 1.9.0-2020.0.5-SNAPSHOT - 1.10.1-SNAPSHOT + 1.10.1 1.2.11 4.5.1 1.12.10