From 6acbb2f07b7f44e35653c32be07d9a802f850abd Mon Sep 17 00:00:00 2001 From: xujianhai666 Date: Sun, 15 Dec 2019 23:24:43 +0800 Subject: [PATCH] feat(registry/zk):url encode zkpath --- remoting/zookeeper/listener.go | 2 ++ remoting/zookeeper/listener_test.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 9521ea7490..d8aa3f6b13 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -18,6 +18,7 @@ package zookeeper import ( + "net/url" "path" "sync" "time" @@ -273,6 +274,7 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da children []string ) + zkPath = url.QueryEscape(zkPath) l.pathMapLock.Lock() _, ok := l.pathMap[zkPath] l.pathMapLock.Unlock() diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go index a90fbad05a..805f1fb462 100644 --- a/remoting/zookeeper/listener_test.go +++ b/remoting/zookeeper/listener_test.go @@ -18,6 +18,7 @@ package zookeeper import ( + "net/url" "sync" "testing" "time" @@ -122,3 +123,9 @@ func (m *mockDataListener) DataChange(eventType remoting.Event) bool { } return true } + +func TestZkPath(t *testing.T) { + zkPath := "io.grpc.examples.helloworld.GreeterGrpc$IGreeter" + zkPath = url.QueryEscape(zkPath) + assert.Equal(t, zkPath, "io.grpc.examples.helloworld.GreeterGrpc%24IGreeter") +} \ No newline at end of file