1kasa commented on code in PR #3134:
URL: https://github.com/apache/dubbo-go/pull/3134#discussion_r2648894488


##########
config_center/file/listener.go:
##########
@@ -147,10 +165,17 @@ func (cl *CacheListener) RemoveListener(key string, 
listener config_center.Confi
        if !loaded {
                return
        }
-       delete(listeners.(map[config_center.ConfigurationListener]struct{}), 
listener)
-       if err := cl.watch.Remove(key); err != nil {
-               logger.Errorf("watcher remove path:%s err:%v", key, err)
+       lmap := listeners.(map[config_center.ConfigurationListener]struct{})
+       delete(lmap, listener)
+       if len(lmap) == 0 {
+               cl.keyListeners.Delete(key)
+               cl.contentCache.Delete(key)
+               if err := cl.watch.Remove(key); err != nil {
+                       logger.Errorf("watcher remove path:%s err:%v", key, err)
+               }
+               return
        }
+       cl.keyListeners.Store(key, lmap)
 }

Review Comment:
   Concurrency is not safe here; consider whether problems might arise.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to