Skip to content

Commit

Permalink
feat(registry/zk):url encode zkpath
Browse files Browse the repository at this point in the history
  • Loading branch information
xujianhai666 committed Dec 15, 2019
1 parent eb434b6 commit 6acbb2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions remoting/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package zookeeper

import (
"net/url"
"path"
"sync"
"time"
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions remoting/zookeeper/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package zookeeper

import (
"net/url"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -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")
}

0 comments on commit 6acbb2f

Please sign in to comment.