From d9d334a512e9de6881822867dc40b8dcb72924ee Mon Sep 17 00:00:00 2001
From: fangyincheng <fangyincheng@sina.com>
Date: Sun, 12 Jan 2020 10:50:07 +0800
Subject: [PATCH] Mod: modidfy Refer params and add licence

---
 config/reference_config.go                      | 10 +++++++---
 config/reference_config_test.go                 |  2 +-
 protocol/dubbo/dubbo_protocol.go                |  2 +-
 protocol/dubbo/dubbo_protocol_test.go           |  2 +-
 protocol/grpc/client.go                         |  6 +++++-
 protocol/grpc/client_test.go                    |  3 +--
 protocol/grpc/grpc_invoker_test.go              |  3 +--
 protocol/grpc/grpc_protocol.go                  |  4 ++--
 protocol/grpc/grpc_protocol_test.go             |  3 +--
 protocol/grpc/internal/client.go                |  5 +++++
 protocol/grpc/internal/helloworld.pb.go         | 17 +++++++++++++++++
 .../grpc/protoc-gen-dubbo/examples/Makefile     | 15 +++++++++++++++
 .../protoc-gen-dubbo/examples/helloworld.pb.go  | 17 +++++++++++++++++
 protocol/jsonrpc/jsonrpc_protocol.go            |  2 +-
 protocol/jsonrpc/jsonrpc_protocol_test.go       |  2 +-
 protocol/protocol.go                            |  4 ++--
 .../protocolwrapper/mock_protocol_filter.go     |  2 +-
 .../protocolwrapper/protocol_filter_wrapper.go  |  4 ++--
 .../protocol_filter_wrapper_test.go             |  2 +-
 registry/directory/directory.go                 |  8 +++-----
 registry/directory/directory_test.go            |  6 +++---
 registry/protocol/protocol.go                   |  4 ++--
 registry/protocol/protocol_test.go              |  6 +++---
 remoting/zookeeper/listener.go                  |  2 --
 24 files changed, 93 insertions(+), 38 deletions(-)

diff --git a/config/reference_config.go b/config/reference_config.go
index 65bbfd2b3..0009dc87c 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -90,7 +90,11 @@ func (refconfig *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) erro
 }
 
 func (refconfig *ReferenceConfig) Refer(impl interface{}) {
-	url := common.NewURLWithOptions(common.WithPath(refconfig.id), common.WithProtocol(refconfig.Protocol), common.WithParams(refconfig.getUrlMap()))
+	url := common.NewURLWithOptions(common.WithPath(refconfig.id),
+		common.WithProtocol(refconfig.Protocol),
+		common.WithParams(refconfig.getUrlMap()),
+		common.WithParamsValue(constant.BEAN_NAME_KEY, refconfig.id),
+	)
 
 	//1. user specified URL, could be peer-to-peer address, or register center's address.
 	if refconfig.Url != "" {
@@ -123,12 +127,12 @@ func (refconfig *ReferenceConfig) Refer(impl interface{}) {
 		}
 	}
 	if len(refconfig.urls) == 1 {
-		refconfig.invoker = extension.GetProtocol(refconfig.urls[0].Protocol).Refer(*refconfig.urls[0], impl)
+		refconfig.invoker = extension.GetProtocol(refconfig.urls[0].Protocol).Refer(*refconfig.urls[0])
 	} else {
 		invokers := []protocol.Invoker{}
 		var regUrl *common.URL
 		for _, u := range refconfig.urls {
-			invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u, impl))
+			invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u))
 			if u.Protocol == constant.REGISTRY_PROTOCOL {
 				regUrl = u
 			}
diff --git a/config/reference_config_test.go b/config/reference_config_test.go
index 39e67c109..7a65e55f0 100644
--- a/config/reference_config_test.go
+++ b/config/reference_config_test.go
@@ -324,7 +324,7 @@ func newRegistryProtocol() protocol.Protocol {
 
 type mockRegistryProtocol struct{}
 
-func (*mockRegistryProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (*mockRegistryProtocol) Refer(url common.URL) protocol.Invoker {
 	return protocol.NewBaseInvoker(url)
 }
 
diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go
index cf395556a..eed22a29c 100644
--- a/protocol/dubbo/dubbo_protocol.go
+++ b/protocol/dubbo/dubbo_protocol.go
@@ -68,7 +68,7 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
 	return exporter
 }
 
-func (dp *DubboProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (dp *DubboProtocol) Refer(url common.URL) protocol.Invoker {
 	//default requestTimeout
 	var requestTimeout = config.GetConsumerConfig().RequestTimeout
 
diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go
index 65ee17a2a..a6b0bc1df 100644
--- a/protocol/dubbo/dubbo_protocol_test.go
+++ b/protocol/dubbo/dubbo_protocol_test.go
@@ -85,7 +85,7 @@ func TestDubboProtocol_Refer(t *testing.T) {
 		"side=provider&timeout=3000&timestamp=1556509797245")
 	assert.NoError(t, err)
 	clientConf = &ClientConfig{}
-	invoker := proto.Refer(url, nil)
+	invoker := proto.Refer(url)
 
 	// make sure url
 	eq := invoker.GetUrl().URLEqual(url)
diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go
index 5ecc9c3ce..01eeb31a7 100644
--- a/protocol/grpc/client.go
+++ b/protocol/grpc/client.go
@@ -18,6 +18,8 @@ limitations under the License.
 package grpc
 
 import (
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/config"
 	"reflect"
 )
 
@@ -34,12 +36,14 @@ type Client struct {
 	invoker reflect.Value
 }
 
-func NewClient(impl interface{}, url common.URL) *Client {
+func NewClient(url common.URL) *Client {
 	conn, err := grpc.Dial(url.Location, grpc.WithInsecure(), grpc.WithBlock())
 	if err != nil {
 		panic(err)
 	}
 
+	key := url.GetParam(constant.BEAN_NAME_KEY, "")
+	impl := config.GetConsumerService(key)
 	invoker := getInvoker(impl, conn)
 
 	return &Client{
diff --git a/protocol/grpc/client_test.go b/protocol/grpc/client_test.go
index 99db4a21c..7d9640278 100644
--- a/protocol/grpc/client_test.go
+++ b/protocol/grpc/client_test.go
@@ -47,9 +47,8 @@ func TestNewClient(t *testing.T) {
 	go internal.InitGrpcServer()
 	defer internal.ShutdownGrpcServer()
 
-	var impl *internal.GrpcGreeterImpl
 	url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown&registry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider&timestamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!")
 	assert.Nil(t, err)
-	cli := NewClient(impl, url)
+	cli := NewClient(url)
 	assert.NotNil(t, cli)
 }
diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go
index 3743236ae..4f97e1063 100644
--- a/protocol/grpc/grpc_invoker_test.go
+++ b/protocol/grpc/grpc_invoker_test.go
@@ -37,11 +37,10 @@ func TestInvoke(t *testing.T) {
 	go internal.InitGrpcServer()
 	defer internal.ShutdownGrpcServer()
 
-	var impl *internal.GrpcGreeterImpl
 	url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown&registry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider&timestamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!")
 	assert.Nil(t, err)
 
-	cli := NewClient(impl, url)
+	cli := NewClient(url)
 
 	invoker := NewGrpcInvoker(url, cli)
 
diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go
index fb2df33bd..cad75752a 100644
--- a/protocol/grpc/grpc_protocol.go
+++ b/protocol/grpc/grpc_protocol.go
@@ -78,8 +78,8 @@ func (gp *GrpcProtocol) openServer(url common.URL) {
 	}
 }
 
-func (gp *GrpcProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker {
-	invoker := NewGrpcInvoker(url, NewClient(impl, url))
+func (gp *GrpcProtocol) Refer(url common.URL) protocol.Invoker {
+	invoker := NewGrpcInvoker(url, NewClient(url))
 	gp.SetInvokers(invoker)
 	logger.Infof("Refer service: %s", url.String())
 	return invoker
diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go
index 541a80da5..e4629499b 100644
--- a/protocol/grpc/grpc_protocol_test.go
+++ b/protocol/grpc/grpc_protocol_test.go
@@ -70,8 +70,7 @@ func TestGrpcProtocol_Refer(t *testing.T) {
 	proto := GetProtocol()
 	url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown&registry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider&timestamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!")
 	assert.NoError(t, err)
-	var impl *internal.GrpcGreeterImpl
-	invoker := proto.Refer(url, impl)
+	invoker := proto.Refer(url)
 
 	// make sure url
 	eq := invoker.GetUrl().URLEqual(url)
diff --git a/protocol/grpc/internal/client.go b/protocol/grpc/internal/client.go
index 4703f4308..5e4149d2c 100644
--- a/protocol/grpc/internal/client.go
+++ b/protocol/grpc/internal/client.go
@@ -19,12 +19,17 @@ package internal
 
 import (
 	"context"
+	"github.com/apache/dubbo-go/config"
 )
 
 import (
 	"google.golang.org/grpc"
 )
 
+func init() {
+	config.SetConsumerService(&GrpcGreeterImpl{})
+}
+
 // used for dubbo-grpc biz client
 type GrpcGreeterImpl struct {
 	SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error
diff --git a/protocol/grpc/internal/helloworld.pb.go b/protocol/grpc/internal/helloworld.pb.go
index 83c2bc253..79b74ac65 100644
--- a/protocol/grpc/internal/helloworld.pb.go
+++ b/protocol/grpc/internal/helloworld.pb.go
@@ -1,3 +1,20 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // source: helloworld.proto
 
diff --git a/protocol/grpc/protoc-gen-dubbo/examples/Makefile b/protocol/grpc/protoc-gen-dubbo/examples/Makefile
index 7df4010b3..7893bbc51 100644
--- a/protocol/grpc/protoc-gen-dubbo/examples/Makefile
+++ b/protocol/grpc/protoc-gen-dubbo/examples/Makefile
@@ -1,3 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 grpc-gen:
 	protoc -I ./ helloworld.proto --go_out=plugins=grpc:.
 dubbo-gen:
diff --git a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
index 33d47e095..4ed55ab76 100644
--- a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
+++ b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
@@ -1,3 +1,20 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // source: helloworld.proto
 
diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go
index 679478766..a2e7afe69 100644
--- a/protocol/jsonrpc/jsonrpc_protocol.go
+++ b/protocol/jsonrpc/jsonrpc_protocol.go
@@ -67,7 +67,7 @@ func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
 	return exporter
 }
 
-func (jp *JsonrpcProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (jp *JsonrpcProtocol) Refer(url common.URL) protocol.Invoker {
 	//default requestTimeout
 	var requestTimeout = config.GetConsumerConfig().RequestTimeout
 
diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go
index 5b6a6043c..253ab830d 100644
--- a/protocol/jsonrpc/jsonrpc_protocol_test.go
+++ b/protocol/jsonrpc/jsonrpc_protocol_test.go
@@ -80,7 +80,7 @@ func TestJsonrpcProtocol_Refer(t *testing.T) {
 		RequestTimeout: 5 * time.Second,
 	}
 	config.SetConsumerConfig(con)
-	invoker := proto.Refer(url, nil)
+	invoker := proto.Refer(url)
 
 	// make sure url
 	eq := invoker.GetUrl().URLEqual(url)
diff --git a/protocol/protocol.go b/protocol/protocol.go
index 93f57b77a..814a85163 100644
--- a/protocol/protocol.go
+++ b/protocol/protocol.go
@@ -29,7 +29,7 @@ import (
 // Extension - protocol
 type Protocol interface {
 	Export(invoker Invoker) Exporter
-	Refer(url common.URL, impl interface{}) Invoker
+	Refer(url common.URL) Invoker
 	Destroy()
 }
 
@@ -74,7 +74,7 @@ func (bp *BaseProtocol) Export(invoker Invoker) Exporter {
 	return NewBaseExporter("base", invoker, bp.exporterMap)
 }
 
-func (bp *BaseProtocol) Refer(url common.URL, impl interface{}) Invoker {
+func (bp *BaseProtocol) Refer(url common.URL) Invoker {
 	return NewBaseInvoker(url)
 }
 
diff --git a/protocol/protocolwrapper/mock_protocol_filter.go b/protocol/protocolwrapper/mock_protocol_filter.go
index 4f1e5638e..2efc34da4 100644
--- a/protocol/protocolwrapper/mock_protocol_filter.go
+++ b/protocol/protocolwrapper/mock_protocol_filter.go
@@ -36,7 +36,7 @@ func (pfw *mockProtocolFilter) Export(invoker protocol.Invoker) protocol.Exporte
 	return protocol.NewBaseExporter("key", invoker, &sync.Map{})
 }
 
-func (pfw *mockProtocolFilter) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (pfw *mockProtocolFilter) Refer(url common.URL) protocol.Invoker {
 	return protocol.NewBaseInvoker(url)
 }
 
diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go
index e9cc54206..7c58fabea 100644
--- a/protocol/protocolwrapper/protocol_filter_wrapper.go
+++ b/protocol/protocolwrapper/protocol_filter_wrapper.go
@@ -50,11 +50,11 @@ func (pfw *ProtocolFilterWrapper) Export(invoker protocol.Invoker) protocol.Expo
 	return pfw.protocol.Export(invoker)
 }
 
-func (pfw *ProtocolFilterWrapper) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (pfw *ProtocolFilterWrapper) Refer(url common.URL) protocol.Invoker {
 	if pfw.protocol == nil {
 		pfw.protocol = extension.GetProtocol(url.Protocol)
 	}
-	return buildInvokerChain(pfw.protocol.Refer(url, impl), constant.REFERENCE_FILTER_KEY)
+	return buildInvokerChain(pfw.protocol.Refer(url), constant.REFERENCE_FILTER_KEY)
 }
 
 func (pfw *ProtocolFilterWrapper) Destroy() {
diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
index 103f0fb53..dc3763135 100644
--- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go
+++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
@@ -54,7 +54,7 @@ func TestProtocolFilterWrapper_Refer(t *testing.T) {
 	u := common.NewURLWithOptions(
 		common.WithParams(url.Values{}),
 		common.WithParamsValue(constant.REFERENCE_FILTER_KEY, "echo"))
-	invoker := filtProto.Refer(*u, nil)
+	invoker := filtProto.Refer(*u)
 	_, ok := invoker.(*FilterInvoker)
 	assert.True(t, ok)
 }
diff --git a/registry/directory/directory.go b/registry/directory/directory.go
index ad4a1cbd5..e88c611f6 100644
--- a/registry/directory/directory.go
+++ b/registry/directory/directory.go
@@ -58,11 +58,10 @@ type registryDirectory struct {
 	configurators                  []config_center.Configurator
 	consumerConfigurationListener  *consumerConfigurationListener
 	referenceConfigurationListener *referenceConfigurationListener
-	impl                           interface{}
 	Options
 }
 
-func NewRegistryDirectory(url *common.URL, impl interface{}, registry registry.Registry, opts ...Option) (*registryDirectory, error) {
+func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...Option) (*registryDirectory, error) {
 	options := Options{
 		//default 300s
 		serviceTTL: time.Duration(300e9),
@@ -80,7 +79,6 @@ func NewRegistryDirectory(url *common.URL, impl interface{}, registry registry.R
 		serviceType:      url.SubURL.Service(),
 		registry:         registry,
 		Options:          options,
-		impl:             impl,
 	}
 	dir.consumerConfigurationListener = newConsumerConfigurationListener(dir)
 	return dir, nil
@@ -200,13 +198,13 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) {
 		dir.overrideUrl(newUrl)
 		if cacheInvoker, ok := dir.cacheInvokersMap.Load(newUrl.Key()); !ok {
 			logger.Infof("service will be added in cache invokers: invokers url is  %s!", newUrl)
-			newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl, dir.impl)
+			newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl)
 			if newInvoker != nil {
 				dir.cacheInvokersMap.Store(newUrl.Key(), newInvoker)
 			}
 		} else {
 			logger.Infof("service will be updated in cache invokers: new invoker url is %s, old invoker url is %s", newUrl, cacheInvoker.(protocol.Invoker).GetUrl())
-			newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl, dir.impl)
+			newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl)
 			if newInvoker != nil {
 				dir.cacheInvokersMap.Store(newUrl.Key(), newInvoker)
 				cacheInvoker.(protocol.Invoker).Destroy()
diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go
index 9af4ef96a..b3c1d35aa 100644
--- a/registry/directory/directory_test.go
+++ b/registry/directory/directory_test.go
@@ -64,7 +64,7 @@ func TestSubscribe(t *testing.T) {
 func TestSubscribe_InvalidUrl(t *testing.T) {
 	url, _ := common.NewURL(context.TODO(), "mock://127.0.0.1:1111")
 	mockRegistry, _ := registry.NewMockRegistry(&common.URL{})
-	_, err := NewRegistryDirectory(&url, nil, mockRegistry)
+	_, err := NewRegistryDirectory(&url, mockRegistry)
 	assert.Error(t, err)
 }
 
@@ -77,7 +77,7 @@ func TestSubscribe_Group(t *testing.T) {
 	suburl.SetParam(constant.CLUSTER_KEY, "mock")
 	regurl.SubURL = &suburl
 	mockRegistry, _ := registry.NewMockRegistry(&common.URL{})
-	registryDirectory, _ := NewRegistryDirectory(&regurl, nil, mockRegistry)
+	registryDirectory, _ := NewRegistryDirectory(&regurl, mockRegistry)
 
 	go registryDirectory.Subscribe(common.NewURLWithOptions(common.WithPath("testservice")))
 
@@ -183,7 +183,7 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR
 	)
 	url.SubURL = &suburl
 	mockRegistry, _ := registry.NewMockRegistry(&common.URL{})
-	registryDirectory, _ := NewRegistryDirectory(&url, nil, mockRegistry)
+	registryDirectory, _ := NewRegistryDirectory(&url, mockRegistry)
 
 	go registryDirectory.Subscribe(&suburl)
 	if len(noMockEvent) == 0 {
diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go
index 1bcc4d72c..8655312a4 100644
--- a/registry/protocol/protocol.go
+++ b/registry/protocol/protocol.go
@@ -89,7 +89,7 @@ func (proto *registryProtocol) initConfigurationListeners() {
 	proto.serviceConfigurationListeners = &sync.Map{}
 	proto.providerConfigurationListener = newProviderConfigurationListener(proto.overrideListeners)
 }
-func (proto *registryProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker {
+func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
 
 	var registryUrl = url
 	var serviceUrl = registryUrl.SubURL
@@ -108,7 +108,7 @@ func (proto *registryProtocol) Refer(url common.URL, impl interface{}) protocol.
 	}
 
 	//new registry directory for store service url from registry
-	directory, err := directory2.NewRegistryDirectory(&registryUrl, impl, reg)
+	directory, err := directory2.NewRegistryDirectory(&registryUrl, reg)
 	if err != nil {
 		logger.Errorf("consumer service %v  create registry directory  error, error message is %s, and will return nil invoker!",
 			serviceUrl.String(), err.Error())
diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go
index 2c407cf2d..0c19da59d 100644
--- a/registry/protocol/protocol_test.go
+++ b/registry/protocol/protocol_test.go
@@ -60,7 +60,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) {
 
 	url.SubURL = &suburl
 
-	invoker := regProtocol.Refer(url, nil)
+	invoker := regProtocol.Refer(url)
 	assert.IsType(t, &protocol.BaseInvoker{}, invoker)
 	assert.Equal(t, invoker.GetUrl().String(), url.String())
 }
@@ -85,7 +85,7 @@ func TestMultiRegRefer(t *testing.T) {
 
 	url2.SubURL = &suburl2
 
-	regProtocol.Refer(url2, nil)
+	regProtocol.Refer(url2)
 	var count int
 	regProtocol.registries.Range(func(key, value interface{}) bool {
 		count++
@@ -107,7 +107,7 @@ func TestOneRegRefer(t *testing.T) {
 
 	url2.SubURL = &suburl2
 
-	regProtocol.Refer(url2, nil)
+	regProtocol.Refer(url2)
 	var count int
 	regProtocol.registries.Range(func(key, value interface{}) bool {
 		count++
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index 96aa45216..0b9db5e09 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -18,7 +18,6 @@
 package zookeeper
 
 import (
-	"fmt"
 	"path"
 	"strings"
 	"sync"
@@ -241,7 +240,6 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
 
 			//listen sub path recursive
 			go func(zkPath string, listener remoting.DataListener) {
-				fmt.Printf("zkpath: %v \n", zkPath)
 				l.listenDirEvent(zkPath, listener)
 				logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath)
 			}(dubboPath, listener)
-- 
GitLab