You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by fa...@apache.org on 2020/08/11 14:50:47 UTC

[dubbo-go] branch develop updated: get application from both dir.url and dir.url.suburl

This is an automated email from the ASF dual-hosted git repository.

fangyc pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 30c587e  get application from both dir.url and dir.url.suburl
     new 25ddfa5  Merge pull request #707 from williamfeng323/bugfix-application-router
30c587e is described below

commit 30c587ebc7c50d0aebed5f9b61ef0c710f2cb143
Author: william feng <>
AuthorDate: Mon Aug 10 18:06:42 2020 +0800

    get application from both dir.url and dir.url.suburl
---
 cluster/directory/base_directory.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go
index 651c90f..20db1f2 100644
--- a/cluster/directory/base_directory.go
+++ b/cluster/directory/base_directory.go
@@ -112,11 +112,15 @@ func (dir *BaseDirectory) SetRouters(urls []*common.URL) {
 
 func (dir *BaseDirectory) isProperRouter(url *common.URL) bool {
 	app := url.GetParam(constant.APPLICATION_KEY, "")
+	dirApp := dir.GetUrl().GetParam(constant.APPLICATION_KEY, "")
+	if len(dirApp) == 0 && dir.GetUrl().SubURL != nil {
+		dirApp = dir.GetUrl().SubURL.GetParam(constant.APPLICATION_KEY, "")
+	}
 	serviceKey := dir.GetUrl().ServiceKey()
-	if serviceKey == "" {
+	if len(serviceKey) == 0 {
 		serviceKey = dir.GetUrl().SubURL.ServiceKey()
 	}
-	if len(app) > 0 && app == dir.GetUrl().GetParam(constant.APPLICATION_KEY, "") {
+	if len(app) > 0 && app == dirApp {
 		return true
 	}
 	if url.ServiceKey() == serviceKey {