runzhiwang commented on a change in pull request #278:
URL: https://github.com/apache/incubator-ratis/pull/278#discussion_r523703178
##########
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:
@szetszwo Hi, I'm not sure whether this reply can respond to the right
request in this multi-thread environment.
Maybe the exception was caused by request1, but currentRef has been set to
request2 immediately.
----------------------------------------------------------------
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]