This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 17470ac [SCB-2378] support publish address configure different port
than listen address (#2726)
17470ac is described below
commit 17470ac4ec08fa2247bbe7787b9de600b0faa0f1
Author: david6969xin <[email protected]>
AuthorDate: Tue Feb 22 09:34:22 2022 +0800
[SCB-2378] support publish address configure different port than listen
address (#2726)
---
.../apache/servicecomb/registry/RegistrationManager.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
index fb4ae57..5c78652 100644
---
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
+++
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
@@ -272,6 +272,12 @@ public class RegistrationManager {
.get();
publicAddressSetting = publicAddressSetting.trim();
+ String publishPortKey = PUBLISH_PORT.replace("{transport_name}", schema);
+ int publishPortSetting = DynamicPropertyFactory.getInstance()
+ .getIntProperty(publishPortKey, 0)
+ .get();
+ int publishPort = publishPortSetting == 0 ? ipPort.getPort() :
publishPortSetting;
+
if (publicAddressSetting.isEmpty()) {
InetSocketAddress socketAddress = ipPort.getSocketAddress();
if (socketAddress.getAddress().isAnyLocalAddress()) {
@@ -282,8 +288,8 @@ public class RegistrationManager {
LOGGER.warn("address {}, auto select a host address to publish {}:{},
maybe not the correct one",
socketAddress,
host,
- socketAddress.getPort());
- return new IpPort(host, ipPort.getPort());
+ publishPort);
+ return new IpPort(host, publishPort);
}
return ipPort;
@@ -296,11 +302,7 @@ public class RegistrationManager {
.getHostAddress();
}
- String publishPortKey = PUBLISH_PORT.replace("{transport_name}", schema);
- int publishPortSetting = DynamicPropertyFactory.getInstance()
- .getIntProperty(publishPortKey, 0)
- .get();
- int publishPort = publishPortSetting == 0 ? ipPort.getPort() :
publishPortSetting;
+
return new IpPort(publicAddressSetting, publishPort);
}