From 75fb930c521bc47b2c1caaa22c0629240f3ca5fe Mon Sep 17 00:00:00 2001 From: zhaoguhong Date: Thu, 14 Apr 2022 15:47:04 +0800 Subject: [PATCH] fix #9910, metadata-report support a separate configuration username and password --- .../org/apache/dubbo/config/MetadataReportConfig.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java index 24b622bdc66..0ce688c6d4f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java @@ -123,9 +123,13 @@ public URL toUrl() throws IllegalArgumentException { map.putAll(convert(map, null)); // put the protocol of URL as the "metadata" map.put("metadata", url.getProtocol()); - return new URL("metadata", url.getUsername(), url.getPassword(), url.getHost(), - url.getPort(), url.getPath(), map); - + return new URL("metadata", + StringUtils.isBlank(url.getUsername()) ? this.getUsername() : url.getUsername(), + StringUtils.isBlank(url.getPassword()) ? this.getPassword() : url.getPassword(), + url.getHost(), + // address port is priority + this.getPort() == null ? url.getPort() : url.getPort(this.getPort()), + url.getPath(), map); } public String getProtocol() {