diff --git a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java index 79b10236227..17ec63c4c47 100644 --- a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java +++ b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java @@ -761,7 +761,8 @@ private final class KeepAlivePinger implements KeepAliveManager.KeepAlivePinger @Override public void ping() { ChannelFuture pingFuture = encoder().writePing( - ctx, false /* isAck */, KEEPALIVE_PING_BUF, ctx.newPromise()); + // slice KEEPALIVE_PING_BUF because tls handler may modify the reader index + ctx, false /* isAck */, KEEPALIVE_PING_BUF.slice(), ctx.newPromise()); ctx.flush(); if (transportTracer != null) { pingFuture.addListener(new ChannelFutureListener() {