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 Norman Maurer
parent 86730f53ca
commit 28ef4d18f9
2 changed files with 9 additions and 0 deletions

View File

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

View File

@ -656,6 +656,14 @@ public class Http2ConnectionHandlerTest {
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
public void channelReadCompleteTriggersFlush() throws Exception {
handler = newHandler();