Skip to content

Commit

Permalink
解决在服务测试,方法执行成功后。动态生成的consumer元数据,host取值为空的问题情况(dubbo version 3.0.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnjxzhao committed Sep 5, 2022
1 parent e677a58 commit 0cfbc55
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.dubbo.common.BaseServiceMetadata;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.url.component.DubboServiceAddressURL;
import org.apache.dubbo.common.utils.StringUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -97,7 +98,13 @@ public static Consumer url2Consumer(Pair<String, URL> pair) {
String version = url.getUrlParam().getParameter(Constants.VERSION_KEY);
String service = BaseServiceMetadata.buildServiceKey(getServiceInterface(url), group, version);
c.setService(service);
c.setAddress(url.getHost());
if (url.getHost() == null) {
if (url instanceof DubboServiceAddressURL) {
c.setAddress(((DubboServiceAddressURL) url).getConsumerURL().getRawParameter("host"));
}
} else {
c.setAddress(url.getHost());
}
c.setApplication(url.getParameter(Constants.APPLICATION_KEY));
c.setParameters(url.toParameterString());

Expand Down

0 comments on commit 0cfbc55

Please sign in to comment.