diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java index 16e1180da5b..db2b583c22c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java @@ -318,7 +318,13 @@ private static boolean isParametersSetter(Method method) { && method.getReturnType() == void.class); } - private static Map convert(Map parameters, String prefix) { + /** + * @param parameters the raw parameters + * @param prefix the prefix + * @return the parameters whose raw key will replace "-" to "." + * @revised 2.7.8 "private" to be "protected" + */ + protected static Map convert(Map parameters, String prefix) { if (parameters == null || parameters.isEmpty()) { return Collections.emptyMap(); } 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 175288c8f5d..dcd43e21ea5 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 @@ -25,6 +25,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DUBBO; import static org.apache.dubbo.common.constants.CommonConstants.PROPERTIES_CHAR_SEPARATOR; +import static org.apache.dubbo.common.utils.StringUtils.isEmpty; /** * MetadataReportConfig @@ -85,20 +86,25 @@ public MetadataReportConfig(String address) { setAddress(address); } - public URL toUrl() { + public URL toUrl() throws IllegalArgumentException { String address = this.getAddress(); - if (StringUtils.isEmpty(address)) { - return null; + if (isEmpty(address)) { + throw new IllegalArgumentException("The address of metadata report is invalid."); } Map map = new HashMap(); + URL url = URL.valueOf(address); + // Issue : https://github.com/apache/dubbo/issues/6491 + // Append the parameters from address + map.putAll(url.getParameters()); + // Append or overrides the properties as parameters appendParameters(map, this); - if (!StringUtils.isEmpty(address)) { - URL url = URL.valueOf(address); - map.put("metadata", url.getProtocol()); - return new URL("metadata", url.getUsername(), url.getPassword(), url.getHost(), - url.getPort(), url.getPath(), map); - } - throw new IllegalArgumentException("The address of metadata report is invalid."); + // Normalize the parameters + 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); + } @Parameter(excluded = true) diff --git a/pom.xml b/pom.xml index d605ae77d78..51b48a07535 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,7 @@ true true - 2.7.8 + 2.7.9-SNAPSHOT