Let Http2ConnectionHandler close stream with voidPromise (#10819)

Motivation:

Http2ConnectionHandler tries to addListener to the future without checking if it's void. If it is void, this will fail and generate an exception. 
 
Modifications:
Unvoid the promise in writeData()
 
Result:

Fixes #10816, Writing with a voidPromise no longer generates exceptions.
This commit is contained in:
valerauko 2020-12-02 18:11:39 +09:00 committed by GitHub
parent c41d46111d
commit b27f0fccce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -120,6 +120,7 @@ public class DefaultHttp2ConnectionEncoder implements Http2ConnectionEncoder, Ht
@Override @Override
public ChannelFuture writeData(final ChannelHandlerContext ctx, final int streamId, ByteBuf data, int padding, public ChannelFuture writeData(final ChannelHandlerContext ctx, final int streamId, ByteBuf data, int padding,
final boolean endOfStream, ChannelPromise promise) { final boolean endOfStream, ChannelPromise promise) {
promise = promise.unvoid();
final Http2Stream stream; final Http2Stream stream;
try { try {
stream = requireStream(streamId); stream = requireStream(streamId);

View File

@ -691,6 +691,14 @@ public class Http2ConnectionHandlerTest {
verify(pipeline).fireExceptionCaught(cause); verify(pipeline).fireExceptionCaught(cause);
} }
@Test
public void canCloseStreamWithVoidPromise() throws Exception {
handler = newHandler();
handler.closeStream(stream, ctx.voidPromise());
verify(stream, times(1)).close();
verifyNoMoreInteractions(stream);
}
@Test @Test
public void channelReadCompleteTriggersFlush() throws Exception { public void channelReadCompleteTriggersFlush() throws Exception {
handler = newHandler(); handler = newHandler();