From b7e153ea57f36f8a515653fdd90100d5394f67a1 Mon Sep 17 00:00:00 2001 From: Joe Zou <yixian.zou@gmail.com> Date: Tue, 22 Sep 2020 11:42:54 +0800 Subject: [PATCH] Merge pull request #747 from cvictory/proxy_invoker_fix ProxyInvoker cannot be extended --- common/proxy/proxy_factory/default.go | 9 +++++++++ registry/protocol/protocol.go | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 1b8ca2220..752f3ea38 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -89,6 +89,8 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati result.SetAttachments(invocation.Attachments()) url := pi.GetUrl() + //get providerUrl. The origin url may be is registry URL. + url = *getProviderURL(&url) methodName := invocation.MethodName() proto := url.Protocol @@ -159,3 +161,10 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati } return result } + +func getProviderURL(url *common.URL) *common.URL { + if url.SubURL == nil { + return url + } + return url.SubURL +} diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 5b2a5d66f..e004d6dfe 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -32,7 +32,6 @@ import ( "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/logger" - "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/config_center" _ "github.com/apache/dubbo-go/config_center/configurator" @@ -403,8 +402,6 @@ func newWrappedInvoker(invoker protocol.Invoker, url *common.URL) *wrappedInvoke // Invoke remote service base on URL of wrappedInvoker func (ivk *wrappedInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - // get right url - ivk.invoker.(*proxy_factory.ProxyInvoker).BaseInvoker = *protocol.NewBaseInvoker(ivk.GetUrl()) return ivk.invoker.Invoke(ctx, invocation) } -- GitLab