修复dubbo注册中心警告bug
dubbo注册中心服务提供者界面显示警告,点击提示不同服务名注册了相同服务,
这是界面显示逻辑bug,源码文件位置:
/dubbo-admin/src/main/webapp/WEB-INF/templates/governance/screen/providers/index.vm
部分代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #set($providerApplication = "") #foreach($provider in $providers) <tr> <td><input type="checkbox" name="ids" value="$provider.id" /></td> <td><a href="providers/$provider.id">#if($address)$tool.getSimpleName($provider.service)#else$provider.address#end</a></td> <td>$tool.getProviderWeight($provider)</td> <td>#if($provider.dynamic)<font color="green">$i18n.get("dynamic")</font>#else<font color="blue">$i18n.get("static")</font>#end</td> <td>#if($tool.isProviderEnabled($provider))<font color="green">$i18n.get("enabled")</font>#else<font color="red">$i18n.get("disabled")</font>#end</td> <td> #set($errorLevel = "ok") #set($errorMessage = "") #if ($providerApplication == "") #set($providerApplication = $provider.application) #end #if($providerApplication != $provider.application) #if ($errorLevel != "error") #set($errorLevel = "warn") #end #set($errorMessage = "$errorMessage<br>$i18n.get('warn'): $i18n.get('CheckProviderApplicationDifferent', $providerApplication, $provider.application)") #end #if($provider.address.startsWith("127.") || $provider.address.startsWith("localhost:") || $provider.address.startsWith("0.0.0.0:"))
|
当判断providerApplication的值和provider.application的值不相同时就给出警告。就成为只要应用名和第一个遍历出来的不一样就加警告。而我们想要的警告是不同应用发布了相同的服务时给出警告。修改后的代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #foreach($provider in $providers) <tr> <td><input type="checkbox" name="ids" value="$provider.id" /></td> <td><a href="providers/$provider.id">#if($address)$tool.getSimpleName($provider.service)#else$provider.address#end</a></td> <td>$tool.getProviderWeight($provider)</td> <td>#if($provider.dynamic)<font color="green">$i18n.get("dynamic")</font>#else<font color="blue">$i18n.get("static")</font>#end</td> <td>#if($tool.isProviderEnabled($provider))<font color="green">$i18n.get("enabled")</font>#else<font color="red">$i18n.get("disabled")</font>#end</td> <td> #set($errorLevel = "ok") #set($errorMessage = "") #foreach($patchProvider in $providers) #if ($patchProvider.application != $provider.application) #if ($provider.service == $patchProvider.service) #if ($errorLevel != "error") #set($errorLevel = "warn") #end #set($errorMessage = "$errorMessage<br>$i18n.get('warn'): $i18n.get('CheckProviderApplicationDifferent', $patchProvider.application, $provider.application)") #break #end #end #end #if($provider.address.startsWith("127.") || $provider.address.startsWith("localhost:") || $provider.address.startsWith("0.0.0.0:"))
|
参考:
https://github.com/alibaba/dubbo/pull/780
http://blog.csdn.net/u012063409/article/details/59110559
错误页面:
修复后