YongGoose commented on code in PR #7349:
URL: https://github.com/apache/incubator-seata/pull/7349#discussion_r2095479027


##########
discovery/seata-discovery-etcd3/src/main/java/org/apache/seata/discovery/registry/etcd3/EtcdRegistryServiceImpl.java:
##########
@@ -401,20 +411,24 @@ public EtcdWatcher(String cluster, Watch.Listener 
listener) {
         @Override
         public void run() {
             Watch watchClient = getClient().getWatchClient();
-            WatchOption.Builder watchOptionBuilder = 
WatchOption.newBuilder().withPrefix(buildRegistryKeyPrefix(cluster));
+            WatchOption.Builder watchOptionBuilder =
+                    
WatchOption.newBuilder().withPrefix(buildRegistryKeyPrefix(cluster));
             Pair<Long /*revision*/, List<InetSocketAddress>> addressPair = 
clusterAddressMap.get(cluster);
             if (Objects.nonNull(addressPair)) {
                 // Maybe addressPair isn't newest now, but it's ok
                 watchOptionBuilder.withRevision(addressPair.getKey());
             }
-            this.watcher = watchClient.watch(buildRegistryKeyPrefix(cluster), 
watchOptionBuilder.build(), this.listener);
+            this.watcher =
+                    watchClient.watch(buildRegistryKeyPrefix(cluster), 
watchOptionBuilder.build(), this.listener);
         }
 
         /**
          * stop this task
          */
         public void stop() {
-            this.watcher.close();
+            if (this.watcher != null) {
+                this.watcher.close();
+            }

Review Comment:
   @funky-eyes 
   
   I add a null check here. What do you think?



-- 
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: notifications-unsubscr...@seata.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to