1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Merge pull request #2037 from wangzhenxyz1/bugfix/invokers_metadata_tag_error

bugfix invokers metadata tag error
This commit is contained in:
TheoneFx 2021-04-23 10:54:51 +08:00 committed by GitHub
commit c76f407038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -308,6 +308,16 @@ public class DubboCloudRegistry extends FailbackRegistry {
String protocol = templateURL.getProtocol(); String protocol = templateURL.getProtocol();
Integer port = repository.getDubboProtocolPort(serviceInstance, Integer port = repository.getDubboProtocolPort(serviceInstance,
protocol); protocol);
// reserve tag
String tag = null;
List<URL> urls = jsonUtils.toURLs(serviceInstance.getMetadata()
.get("dubbo.metadata-service.urls"));
if (urls != null && urls.size() > 0) {
Map<String, String> parameters = urls.get(0).getParameters();
tag = parameters.get("dubbo.tag");
}
if (Objects.equals(templateURL.getHost(), host) if (Objects.equals(templateURL.getHost(), host)
&& Objects.equals(templateURL.getPort(), port)) { // use && Objects.equals(templateURL.getPort(), port)) { // use
// templateURL // templateURL
@ -331,7 +341,8 @@ public class DubboCloudRegistry extends FailbackRegistry {
// the template // the template
// URL // URL
.setHost(host) // reset the host .setHost(host) // reset the host
.setPort(port); // reset the port .setPort(port) // reset the port
.addParameter("dubbo.tag", tag); // reset the tag
return clonedURLBuilder.build(); return clonedURLBuilder.build();
} }