ywxzm03 commented on code in PR #3612:
URL: https://github.com/apache/dubbo-go/pull/3612#discussion_r3786643315


##########
config_center/zookeeper/impl.go:
##########


Review Comment:
   fixed



##########
config_center/zookeeper/listener_test.go:
##########
@@ -62,6 +68,48 @@ func TestCacheListenerDataChangeEmptyContent(t *testing.T) {
        if len(rec.events) != 1 || rec.events[0].ConfigType != 
remoting.EventTypeDel {
                t.Fatalf("unexpected events %+v", rec.events)
        }
+       entry, ok := cache.getFresh(path)
+       if !ok || !entry.exists || entry.content != "" {
+               t.Fatalf("empty configuration should be cached as existing: 
%+v", entry)
+       }
+
+       l.DataChange(remoting.Event{Path: path, Action: remoting.EventTypeDel})
+       entry, ok = cache.getFresh(path)
+       if !ok || entry.exists {
+               t.Fatalf("deleted configuration should be cached as missing: 
%+v", entry)
+       }
+}
+
+func TestCacheListenerIgnoresEventAcrossReset(t *testing.T) {
+       cache := newConfigCache(time.Minute)
+       l := &CacheListener{rootPath: "/dubbo/config", cache: &cache}
+       path := "/dubbo/config/group/app"
+       pathLock := cache.pathLock(path)
+       pathLock.Lock()
+       watchStateDone := make(chan struct{})
+       go func() {
+               l.WatchStateChanged(path, false)
+               close(watchStateDone)
+       }()
+       require.Eventually(t, func() bool {
+               _, ok := l.eventGeneration.Load(path)
+               return ok
+       }, time.Second, time.Millisecond)
+
+       cache.reset()
+       pathLock.Unlock()
+       <-watchStateDone
+       l.WatchStateChanged(path, true)
+       l.DataChange(remoting.Event{Path: path, Action: 
remoting.EventTypeUpdate, Content: "old"})
+
+       _, ok := cache.getFresh(path)
+       if ok {
+               t.Fatal("event started before reset should not repopulate 
cache")
+       }
+       _, watchActive := cache.snapshot(path)
+       if watchActive {
+               t.Fatal("event started before reset should not reactivate watch 
state")
+       }

Review Comment:
   fixed



-- 
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