szetszwo commented on a change in pull request #278:
URL: https://github.com/apache/incubator-ratis/pull/278#discussion_r523703693



##########
File path: 
ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -151,11 +152,23 @@ public void addRaftPeers(Collection<RaftPeer> newPeers) {
 
   private ChannelInboundHandler newChannelInboundHandlerAdapter(){
     return new ChannelInboundHandlerAdapter(){
+      private final AtomicReference<DataStreamRequestByteBuf> currentRef = new 
AtomicReference<>();
+
       @Override
       public void channelRead(ChannelHandlerContext ctx, Object msg) {
-        if (msg instanceof DataStreamRequestByteBuf) {
-          requests.read((DataStreamRequestByteBuf)msg, ctx, 
proxies::getDataStreamOutput);
+        if (!(msg instanceof DataStreamRequestByteBuf)) {
+          LOG.error("Unexpected message class {}, ignoring ...", 
msg.getClass().getName());
+          return;
         }
+
+        final DataStreamRequestByteBuf current = (DataStreamRequestByteBuf) 
msg;
+        currentRef.set(current);
+        requests.read(current, ctx, proxies::getDataStreamOutput);
+      }
+
+      @Override
+      public void exceptionCaught(ChannelHandlerContext ctx, Throwable 
throwable) {
+        DataStreamManagement.sendException(currentRef.get(), throwable, ctx);

Review comment:
       It seems won't happen in Netty.  Let's test it. 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to