DefaultHttp2ConnectionDecoder write ping buffer

Motivation:
DefaultHttp2ConnectionDecoder writes a ACK when receiving a ping frame and sends the same data buffer it received. The data buffer is also passed to the listener, but the indexes are shared between the send and the listener. We should ensure the indexes are independent for these two operations.

Modifications:
- Call slice on the buffer that is being sent

Result:
Listener now has access to a buffer that will not appear to be already consumed.
This commit is contained in:
Scott Mitchell 2015-10-02 10:41:40 -07:00
parent 5deec9631f
commit 06c3ae07a0

View File

@ -442,7 +442,7 @@ public class DefaultHttp2ConnectionDecoder implements Http2ConnectionDecoder {
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
// Send an ack back to the remote client.
// Need to retain the buffer here since it will be released after the write completes.
encoder.writePing(ctx, true, data.retain(), ctx.newPromise());
encoder.writePing(ctx, true, data.slice().retain(), ctx.newPromise());
listener.onPingRead(ctx, data);
}