You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by il...@apache.org on 2019/07/17 03:15:34 UTC

[dubbo] branch master updated: fix bug of Etcd3Registry cancel watch #4357 (#4358)

This is an automated email from the ASF dual-hosted git repository.

iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new e3c9bed  fix bug of Etcd3Registry cancel watch #4357 (#4358)
e3c9bed is described below

commit e3c9bed84b7ebab124009ebbe4565fd6020b2822
Author: HzjNeverStop <44...@qq.com>
AuthorDate: Wed Jul 17 11:15:28 2019 +0800

    fix bug of Etcd3Registry cancel watch #4357 (#4358)
    
    * fix bug of Etcd3Registry cancel watch
    
    * optimize bugfix for etcd3 registry cancel watch
---
 .../org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
index 4c055b4..4f3ab93 100644
--- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
+++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java
@@ -447,8 +447,17 @@ public class JEtcdClient extends AbstractEtcdClient<JEtcdClient.EtcdWatcher> {
             if (this.watchRequest == null) {
                 return;
             }
-            this.watchRequest.onCompleted();
-            this.watchRequest = null;
+
+            try {
+                WatchCancelRequest watchCancelRequest =
+                        WatchCancelRequest.newBuilder().setWatchId(watchId).build();
+                WatchRequest cancelRequest = WatchRequest.newBuilder()
+                        .setCancelRequest(watchCancelRequest).build();
+                watchRequest.onNext(cancelRequest);
+            } finally {
+                this.watchRequest.onCompleted();
+                this.watchRequest = null;
+            }
         }
 
         @Override