From b9b057dcef1d4c48b23d52e03fb3d73e0bd9a43f Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Fri, 6 Jan 2023 16:56:29 +0800 Subject: [PATCH] fix:fix nacos enabled condition bugs. (#793) --- CHANGELOG.md | 1 + .../polaris/discovery/DiscoveryEnabledCondition.java | 8 ++++++++ .../cloud/polaris/registry/RegisterEnabledCondition.java | 9 +++++++++ spring-cloud-tencent-dependencies/pom.xml | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff22e3b37..d61f2244d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,3 +24,4 @@ - [Bugfix: fix reactor concurrent bug when get instances & fix spring-retry fuse not working bug](https://github.com/Tencent/spring-cloud-tencent/pull/774) - [Standardize the name of method to create bean.](https://github.com/Tencent/spring-cloud-tencent/pull/779) - [set reporter.enabled default to true](https://github.com/Tencent/spring-cloud-tencent/pull/784) +- [fix:fix nacos enabled condition bugs.](https://github.com/Tencent/spring-cloud-tencent/pull/793) 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 50d96d36e..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 @@ -40,6 +40,14 @@ public class DiscoveryEnabledCondition implements Condition { conditionContext.getEnvironment().getProperty("spring.cloud.consul.discovery.enabled", "true")); isDiscoveryEnabled |= isConsulDiscoveryEnabled; + + 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 d98d60185..b06f4f0c9 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 0d3b19f10..9d676e80b 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -73,7 +73,7 @@ 1.9.0-2021.0.3-SNAPSHOT - 1.10.1-SNAPSHOT + 1.10.1 31.0.1-jre 1.2.11 4.5.1