fix:fix random port read bug. (#1000)

pull/1007/head
Haotian Zhang 1 year ago committed by GitHub
parent 0ab19edb7a
commit beefb50f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,3 +7,4 @@
- [Feature: add AssemblyFlow to support tsf.](https://github.com/Tencent/spring-cloud-tencent/pull/992) - [Feature: add AssemblyFlow to support tsf.](https://github.com/Tencent/spring-cloud-tencent/pull/992)
- [feat:refactor SDKContext as static.](https://github.com/Tencent/spring-cloud-tencent/pull/995) - [feat:refactor SDKContext as static.](https://github.com/Tencent/spring-cloud-tencent/pull/995)
- [Refactoring: Refactor Circuitbreaker ut.](https://github.com/Tencent/spring-cloud-tencent/pull/996) - [Refactoring: Refactor Circuitbreaker ut.](https://github.com/Tencent/spring-cloud-tencent/pull/996)
- [fix:fix random port read bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1000)

@ -78,7 +78,7 @@ Spring Cloud Tencent 所有组件都已上传到 Maven 中央仓库,只需要
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-dependencies</artifactId> <artifactId>spring-cloud-tencent-dependencies</artifactId>
<!--version number--> <!--version number-->
<version>1.11.2-2022.0.1</version> <version>1.11.4-2022.0.1</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

@ -80,7 +80,7 @@ For example:
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-dependencies</artifactId> <artifactId>spring-cloud-tencent-dependencies</artifactId>
<!--version number--> <!--version number-->
<version>1.11.2-2022.0.1</version> <version>1.11.4-2022.0.1</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

@ -127,7 +127,7 @@ public class PolarisSDKContextManager {
// init SDKContext // init SDKContext
sdkContext = SDKContext.initContextByConfig(properties.configuration(modifierList, sdkContext = SDKContext.initContextByConfig(properties.configuration(modifierList,
() -> environment.getProperty("spring.cloud.client.ip-address"), () -> environment.getProperty("spring.cloud.client.ip-address"),
() -> environment.getProperty("server.port", Integer.class, 0))); () -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0)));
sdkContext.init(); sdkContext.init();
// init ProviderAPI // init ProviderAPI

@ -83,10 +83,8 @@ public class PolarisContextProperties {
defaultHost = ipAddressSupplier.get(); defaultHost = ipAddressSupplier.get();
this.localIpAddress = defaultHost; this.localIpAddress = defaultHost;
} }
Integer defaultPort = this.localPort;
if (this.localPort == null || this.localPort <= 0) { if (this.localPort == null || this.localPort <= 0) {
defaultPort = portSupplier.get(); this.localPort = portSupplier.get();
this.localPort = defaultPort;
} }
configuration.getGlobal().getAPI().setBindIP(defaultHost); configuration.getGlobal().getAPI().setBindIP(defaultHost);
@ -157,10 +155,10 @@ public class PolarisContextProperties {
return "PolarisContextProperties{" + return "PolarisContextProperties{" +
"address='" + address + '\'' + "address='" + address + '\'' +
", localIpAddress='" + localIpAddress + '\'' + ", localIpAddress='" + localIpAddress + '\'' +
", localPort=" + localPort + ((this.localPort == null || this.localPort <= 0) ? "" : ", localPort=" + localPort) +
", enabled=" + enabled + ", enabled=" + enabled +
", namespace='" + namespace + '\'' + ", namespace='" + namespace + '\'' +
", service='" + service + '\'' + ((StringUtils.isBlank(this.service)) ? "" : ", service='" + service + '\'') +
'}'; '}';
} }
} }

Loading…
Cancel
Save