From 8458c8872a1f2d3ee58b4dddfcfedeffc3af0b54 Mon Sep 17 00:00:00 2001
From: Ian Luo <ian.luo@gmail.com>
Date: Thu, 13 Aug 2020 10:41:55 +0800
Subject: [PATCH] use defer to unlock

---
 cluster/router/chain/chain.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index 091bcaa05..1c7d48aef 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -188,9 +188,9 @@ func (c *RouterChain) buildCache() {
 			go func(p router.Poolable) {
 				pool, info := poolRouter(p, origin, invokers)
 				mutex.Lock()
+				defer mutex.Unlock()
 				cache.pools[p.Name()] = pool
 				cache.metadatas[p.Name()] = info
-				mutex.Unlock()
 				wg.Done()
 			}(p)
 		}
-- 
GitLab