lymerin opened a new pull request, #7372: URL: https://github.com/apache/shenyu/pull/7372
Fixes #6526 . ## Problem `ZookeeperInstanceRegisterRepository.selectInstances()` caches the instances returned by ZooKeeper. When the last instance child is removed, the watcher receives an empty child list, but its callback only updates the cache when that list is non-empty. As a result, the previous instance list remains in `watcherInstanceRegisterMap`. Later calls to `selectInstances()` return that cached list immediately, so an instance that no longer exists in ZooKeeper still appears available. ## Changes Update the cache for every child-list result, including an empty list. When the last child is removed, `selectInstances()` now returns an empty list instead of the stale instances. The empty list remains a cached result. Subsequent reads therefore use the existing watcher; they do not register another watcher simply because the service currently has no instances. When a new child appears, the watcher updates the cache with the new instance list. The existing watcher test now checks all three states: one instance is present, the last instance is removed, and an instance appears again. ## Testing - Ran the ZooKeeper registry module tests: **3 passed, 0 failed**. - Confirmed the new empty-list assertion failed before the production change and passed after it. Make sure that: - [x] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide). - [x] You submit test cases (unit or integration tests) that back your changes. - [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`. -- 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]
