You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/07/26 01:16:54 UTC
[dubbo] branch 3.0 updated: fix: metadata service port error when config DUBBO_PORT_TO_REGISTRY env (#10364)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new e3cc8595dc fix: metadata service port error when config DUBBO_PORT_TO_REGISTRY env (#10364)
e3cc8595dc is described below
commit e3cc8595dc56eb2a1107d8ea5f4f73312025aa71
Author: monkeyWie <li...@qq.com>
AuthorDate: Tue Jul 26 09:16:42 2022 +0800
fix: metadata service port error when config DUBBO_PORT_TO_REGISTRY env (#10364)
---
.../config/metadata/ConfigurableMetadataServiceExporter.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java
index 481fdd0564..778b7c36a5 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java
@@ -45,6 +45,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE
import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE_PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
+import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
/**
* Export metadata service
@@ -122,8 +123,12 @@ public class ConfigurableMetadataServiceExporter {
// metadata service may export before normal service export, it.hasNext() will return false.
// so need use specified protocol port.
if (it.hasNext()) {
- String addr = it.next().getAddress();
- String rawPort = addr.substring(addr.indexOf(":") + 1);
+ ProtocolServer server = it.next();
+ String rawPort = server.getUrl().getParameter(BIND_PORT_KEY);
+ if (rawPort == null) {
+ String addr = server.getAddress();
+ rawPort = addr.substring(addr.indexOf(":") + 1);
+ }
protocolConfig.setPort(Integer.parseInt(rawPort));
} else {
Integer protocolPort = getProtocolConfig(specifiedProtocol).getPort();