You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2021/11/29 10:21:33 UTC
[GitHub] [ratis] guohao-rosicky commented on a change in pull request #541: RATIS-1445. NettyClientStreamRpc exception handling
guohao-rosicky commented on a change in pull request #541:
URL: https://github.com/apache/ratis/pull/541#discussion_r758221148
##########
File path: ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java
##########
@@ -118,14 +121,23 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
final DataStreamReply reply = (DataStreamReply) msg;
LOG.debug("{}: read {}", this, reply);
- ClientInvocationId clientInvocationId = ClientInvocationId.valueOf(reply.getClientId(), reply.getStreamId());
+ clientInvocationId = ClientInvocationId.valueOf(reply.getClientId(), reply.getStreamId());
Optional.ofNullable(replies.get(clientInvocationId))
.map(Queue::poll)
.ifPresent(f -> f.complete(reply));
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+ Optional.ofNullable(clientInvocationId).ifPresent(id ->
+ Optional.ofNullable(replies.get(id)).ifPresent(q -> {
+ for (int i = 0; i < q.size(); i++) {
+ CompletableFuture<DataStreamReply> f = q.poll();
+ f.completeExceptionally(cause);
+ }
+ replies.remove(id);
+ })
+ );
Review comment:
Has been modified @szetszwo
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org