fix:fix nacos enabled condition bugs. (#795)

pull/805/head
Haotian Zhang 2 years ago committed by GitHub
parent 012eb0bcc7
commit 22e12b5152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,3 +19,4 @@
- [Test:add sct-stater-polaris-router junit.](https://github.com/Tencent/spring-cloud-tencent/pull/768) - [Test:add sct-stater-polaris-router junit.](https://github.com/Tencent/spring-cloud-tencent/pull/768)
- [Optimize: add equals&hasCode for PolarisServiceInstance](https://github.com/Tencent/spring-cloud-tencent/pull/773) - [Optimize: add equals&hasCode for PolarisServiceInstance](https://github.com/Tencent/spring-cloud-tencent/pull/773)
- [Fix issue: prompt no registration if web dependence was not imported.](https://github.com/Tencent/spring-cloud-tencent/pull/778) - [Fix issue: prompt no registration if web dependence was not imported.](https://github.com/Tencent/spring-cloud-tencent/pull/778)
- [fix:fix nacos enabled condition bugs.](https://github.com/Tencent/spring-cloud-tencent/pull/795)

@ -36,12 +36,18 @@ public class DiscoveryEnabledCondition implements Condition {
boolean isConsulDiscoveryEnabled = Boolean.parseBoolean( boolean isConsulDiscoveryEnabled = Boolean.parseBoolean(
conditionContext.getEnvironment().getProperty("spring.cloud.consul.enabled", "false")) conditionContext.getEnvironment().getProperty("spring.cloud.consul.enabled", "false"))
&& Boolean.parseBoolean(conditionContext.getEnvironment() && Boolean.parseBoolean(
.getProperty("spring.cloud.consul.discovery.enabled", "true")); conditionContext.getEnvironment().getProperty("spring.cloud.consul.discovery.enabled", "true"));
boolean isNacosEnabled = Boolean.parseBoolean( isDiscoveryEnabled |= isConsulDiscoveryEnabled;
conditionContext.getEnvironment().getProperty("spring.cloud.nacos.discovery.enabled", "false"));
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;
} }
} }

@ -39,6 +39,15 @@ public class RegisterEnabledCondition implements Condition {
.getProperty("spring.cloud.consul.discovery.register", "true")); .getProperty("spring.cloud.consul.discovery.register", "true"));
isRegisterEnabled |= isConsulRegisterEnabled; 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; return isRegisterEnabled;
} }
} }

@ -71,7 +71,7 @@
<properties> <properties>
<revision>1.9.0-Hoxton.SR12-SNAPSHOT</revision> <revision>1.9.0-Hoxton.SR12-SNAPSHOT</revision>
<polaris.version>1.10.1-SNAPSHOT</polaris.version> <polaris.version>1.10.1</polaris.version>
<logback.version>1.2.11</logback.version> <logback.version>1.2.11</logback.version>
<mocktio.version>4.5.1</mocktio.version> <mocktio.version>4.5.1</mocktio.version>
<byte-buddy.version>1.12.10</byte-buddy.version> <byte-buddy.version>1.12.10</byte-buddy.version>
@ -247,6 +247,12 @@
<version>${bcprov-jdk15on.version}</version> <version>${bcprov-jdk15on.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId> <artifactId>mockito-inline</artifactId>

Loading…
Cancel
Save