Skip to content

Commit

Permalink
Merge pull request #613 from wenxuwan/master
Browse files Browse the repository at this point in the history
Fix: zk disconnected, dubbo-go panic when subscribe.
  • Loading branch information
pantianying authored Jun 28, 2020
2 parents 21245ba + 322ca31 commit 2550126
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion remoting/zookeeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
type ZookeeperClient struct {
name string
ZkAddrs []string
sync.Mutex // for conn
sync.RWMutex // for conn
Conn *zk.Conn
Timeout time.Duration
exit chan struct{}
Expand Down
8 changes: 7 additions & 1 deletion remoting/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,14 @@ func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listen
l.pathMapLock.Lock()
l.pathMap[dubboPath] = struct{}{}
l.pathMapLock.Unlock()

//When Zk disconnected, the Conn will be set to nil, so here need check the value of Conn
l.client.RLock()
if l.client.Conn == nil {
l.client.RUnlock()
break
}
content, _, err := l.client.Conn.Get(dubboPath)
l.client.RUnlock()
if err != nil {
logger.Errorf("Get new node path {%v} 's content error,message is {%v}", dubboPath, perrors.WithStack(err))
}
Expand Down

0 comments on commit 2550126

Please sign in to comment.