Skip to content

Commit

Permalink
Fix error when host is null (#920)
Browse files Browse the repository at this point in the history
* 解决重复点功能,浏览器控制台报错问题,如点击:服务查询-搜索按钮

* 解决可能产生的空指针问题,导致 '消费者'标签无法显示数据

* 解决在服务测试,方法执行成功后。动态生成的consumer元数据,host取值为空的问题情况(dubbo version 3.0.8)
  • Loading branch information
cnjxzhao committed Sep 6, 2022
1 parent 44dfccc commit c7bc09a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions dubbo-admin-ui/src/components/ServiceDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@
})
},
getIp: function (address) {
return address.split(':')[0]
return address != null ? address.split(':')[0] : null
},
getPort: function (address) {
return address.split(':')[1]
return address != null && address.split(':').length >= 1 ? address.split(':')[1] : null
},
toCopyText (text) {
this.$copyText(text).then(() => {
Expand Down

0 comments on commit c7bc09a

Please sign in to comment.