chaoyoung commented on code in PR #16585:
URL: https://github.com/apache/dubbo/pull/16585#discussion_r4585751643


##########
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/http2/GenericHttp2ServerTransportListener.java:
##########
@@ -229,9 +293,54 @@ protected final Http2ServerChannelObserver 
getResponseObserver() {
 
     @Override
     public void close() {
+        closeInputs();
         responseObserver.close();
     }
 
+    private void closeInputs() {
+        synchronized (inputLock) {
+            inputClosed = true;
+            if (processingInputs == 0) {
+                closePendingInputs();
+            }
+        }
+    }
+
+    private void closePendingInputs() {
+        // An already-started callback may still be preparing its DATA 
message. Defer
+        // pre-delivery cleanup until it returns; accepted input belongs to 
the decoder.
+        for (PendingInput input : pendingInputs) {
+            closeInput(input);
+        }
+    }

Review Comment:
   Confirmed and fixed in f6432631cf. Pending inputs are now detached into a 
snapshot under inputLock and closed after releasing the lock. Cleanup still 
waits until all started DATA callbacks leave the handoff, so it does not close 
a body being prepared for the decoder. The new 
closeCallbackCanWaitForConcurrentLateData regression times out on the prior 
lock-held implementation and passes with this change. I also added a red/green 
regression for unchecked close failures: each input is closed independently, so 
a RuntimeException from one close does not abandon the remaining detached 
inputs. Repeated close still releases each original body only once.



##########
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/websocket/DefaultWebSocketServerTransportListener.java:
##########
@@ -99,6 +99,25 @@ protected void onDataCompletion(Http2InputMessage message) {
         super.onDataCompletion(message);
     }
 
+    @Override
+    protected PendingInput newPendingInput(Http2InputMessage message) {
+        return message.getBody() instanceof 
org.apache.dubbo.remoting.websocket.FinalFragment
+                ? new PendingFragmentInput(message)
+                : super.newPendingInput(message);
+    }
+
+    private final class PendingFragmentInput extends PendingInput
+            implements org.apache.dubbo.remoting.websocket.FinalFragment {
+        private PendingFragmentInput(Http2InputMessage message) {
+            super(message);
+        }
+
+        @Override
+        public boolean isFinalFragment() {
+            return ((org.apache.dubbo.remoting.websocket.FinalFragment) 
in).isFinalFragment();
+        }
+    }

Review Comment:
   Applied in f6432631cf: FinalFragment is imported once and the repeated fully 
qualified references are removed. The marker-preserving adapter remains 
confined to the WebSocket-specific listener; the generic HTTP/gRPC listener 
still has no dependency on the optional WebSocket module. Formatting checks and 
the real Netty/Tomcat WebSocket sample tests passed before pushing.



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