Skip to content

Commit 405f337

Browse files
committed
Save changes.
1 parent f5ecf1b commit 405f337

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

netty/src/main/java/io/grpc/netty/NettyServerHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121
import static io.grpc.internal.GrpcUtil.SERVER_KEEPALIVE_TIME_NANOS_DISABLED;
22+
import static io.grpc.netty.NettyClientHandler.NOOP_MESSAGE;
2223
import static io.grpc.netty.NettyServerBuilder.MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE;
2324
import static io.grpc.netty.NettyServerBuilder.MAX_CONNECTION_AGE_NANOS_DISABLED;
2425
import static io.grpc.netty.NettyServerBuilder.MAX_CONNECTION_IDLE_NANOS_DISABLED;
@@ -709,6 +710,8 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
709710
gracefulClose(ctx, (GracefulServerCloseCommand) msg, promise);
710711
} else if (msg instanceof ForcefulCloseCommand) {
711712
forcefulClose(ctx, (ForcefulCloseCommand) msg, promise);
713+
} else if (msg == NOOP_MESSAGE) {
714+
ctx.write(Unpooled.EMPTY_BUFFER, promise);
712715
} else {
713716
AssertionError e =
714717
new AssertionError("Write called for unexpected type: " + msg.getClass().getName());

netty/src/main/java/io/grpc/netty/NettyServerTransport.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public void operationComplete(ChannelFuture future) throws Exception {
160160
channel.closeFuture().addListener(terminationNotifier);
161161

162162
channel.pipeline().addLast(bufferingHandler);
163+
channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() {
164+
@Override
165+
public void operationComplete(ChannelFuture future) throws Exception {
166+
if (!future.isSuccess()) {
167+
notifyTerminated(future.cause());
168+
}
169+
}
170+
});
163171
}
164172

165173
@Override

0 commit comments

Comments
 (0)