szetszwo commented on code in PR #1179:
URL: https://github.com/apache/ratis/pull/1179#discussion_r1855321689


##########
ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java:
##########
@@ -459,7 +461,12 @@ private void readImpl(DataStreamRequestByteBuf request, 
ChannelHandlerContext ct
       localWrite = CompletableFuture.completedFuture(0L);
       remoteWrites = Collections.emptyList();
     } else if (request.getType() == Type.STREAM_DATA) {
-      localWrite = info.getLocal().write(request.slice(), 
request.getWriteOptionList(), writeExecutor);
+      if (close && request.getDataLength() == 0) {

Review Comment:
   @symious , you are right that we still need to forward the close request.  
You original code is better.  How about below?
   
   ```diff
   @@ -459,7 +460,11 @@ public class DataStreamManagement {
          localWrite = CompletableFuture.completedFuture(0L);
          remoteWrites = Collections.emptyList();
        } else if (request.getType() == Type.STREAM_DATA) {
   -      localWrite = info.getLocal().write(request.slice(), 
request.getWriteOptionList(), writeExecutor);
   +      if (close && request.getDataLength() == 0) {
   +        localWrite = CompletableFuture.completedFuture(0L);
   +      } else {
   +        localWrite = info.getLocal().write(request.slice(), 
request.getWriteOptionList(), writeExecutor);
   +      }
          remoteWrites = info.applyToRemotes(out -> out.write(request, 
requestExecutor));
        } else {
          throw new IllegalStateException(this + ": Unexpected type " + 
request.getType() + ", request=" + request);
   @@ -479,7 +484,12 @@ public class DataStreamManagement {
          try {
            if (exception != null) {
              replyDataStreamException(server, exception, info.getRequest(), 
request, ctx);
   -          removeDataStream(key, info);
   +        }
   +        if (close || exception != null) {
   +          final StreamInfo removed = removeDataStream(key);
   +          if (removed != null) {
   +            Preconditions.assertSame(info, removed, "removed");
   +          }
            }
          } finally {
            request.release();
   ```



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

Reply via email to