From 746ee8a425eb5ee48ccc82c6c2ec08de64355650 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E4=BF=A1?=
 <lizhixin@B-C0A1LVDL-2144.local>
Date: Thu, 31 Dec 2020 14:24:48 +0800
Subject: [PATCH] fix: fix test and add another gr to push notify

---
 cluster/router/chain/chain.go      | 4 +++-
 cluster/router/chain/chain_test.go | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index 57788975e..0e175ddf2 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -104,7 +104,9 @@ func (c *RouterChain) AddRouters(routers []router.PriorityRouter) {
 	c.mutex.Lock()
 	defer c.mutex.Unlock()
 	c.routers = newRouters
-	c.notify <- struct{}{}
+	go func() {
+		c.notify <- struct{}{}
+	}()
 }
 
 // SetInvokers receives updated invokers from registry center. If the times of notification exceeds countThreshold and
diff --git a/cluster/router/chain/chain_test.go b/cluster/router/chain/chain_test.go
index f274d1b31..b4b3d7270 100644
--- a/cluster/router/chain/chain_test.go
+++ b/cluster/router/chain/chain_test.go
@@ -143,6 +143,11 @@ conditions:
 	assert.NotNil(t, url)
 	factory := extension.GetRouterFactory(url.Protocol)
 	notify := make(chan struct{})
+	go func() {
+		for {
+			<-notify
+		}
+	}()
 	r, err := factory.NewPriorityRouter(url, notify)
 	assert.Nil(t, err)
 	assert.NotNil(t, r)
-- 
GitLab