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


##########
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 , Good catch for this case!  There is no write here.  We should 
   - do the same as `request.getType() == Type.STREAM_HEADER`, and
   - call `removeDataStream` for close.
   ```diff
   @@ -455,7 +456,8 @@ public class DataStreamManagement {
    
        final CompletableFuture<Long> localWrite;
        final List<CompletableFuture<DataStreamReply>> remoteWrites;
   -    if (request.getType() == Type.STREAM_HEADER) {
   +    if (request.getType() == Type.STREAM_HEADER
   +        || (close && request.getDataLength() == 0)) {
          localWrite = CompletableFuture.completedFuture(0L);
          remoteWrites = Collections.emptyList();
        } else if (request.getType() == Type.STREAM_DATA) {
   @@ -479,7 +481,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