funky-eyes commented on code in PR #7752:
URL: https://github.com/apache/incubator-seata/pull/7752#discussion_r2480365658


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -107,21 +111,43 @@ private void sendWatcherResponse(Watcher<HttpContext> 
watcher, HttpResponseStatu
             return;
         }
         ChannelHandlerContext ctx = context.getContext();
+        if (!ctx.channel().isActive()) {
+            logger.warn(
+                    "Netty channel is not active for watcher on group {}, 
cannot send response.", watcher.getGroup());
+            return;
+        }
         if (!context.isHttp2()) {
-            if (ctx.channel().isActive()) {
-                HttpResponse response =
-                        new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, 
nettyStatus, Unpooled.EMPTY_BUFFER);
-                response.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
-
-                if (!context.isKeepAlive()) {
-                    
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
-                } else {
-                    ctx.writeAndFlush(response);
-                }
+            HttpResponse response =
+                    new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, 
nettyStatus, Unpooled.EMPTY_BUFFER);
+            response.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
+
+            if (!context.isKeepAlive()) {
+                
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
             } else {
-                logger.warn(
-                        "Netty channel is not active for watcher on group {}, 
cannot send response.",
-                        watcher.getGroup());
+                ctx.writeAndFlush(response);
+            }
+        } else {
+            try {
+
+                Http2Headers headers = new 
DefaultHttp2Headers().status(nettyStatus.codeAsText());
+                headers.set(HttpHeaderNames.CONTENT_LENGTH, "0");
+
+                ctx.write(new DefaultHttp2HeadersFrame(headers));
+                ctx.write(new DefaultHttp2DataFrame(Unpooled.EMPTY_BUFFER, 
true));

Review Comment:
   I want to keep this connection open and reuse it to deliver updates whenever 
the leader changes, rather than requiring the client to open a new HTTP/2 watch 
request after every response.



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