Support cancellation in the Http2StreamChannelBootstrap (#9519)

Motivation:

Right now you can cancel the Future returned by
`Http2StreamChannelBootstrap.open()` and that will race with the
registration of the stream channel with the event loop, potentially
culminating in an `IllegalStateException` and potential resource leak.

Modification:

Ensure that the returned promise is uncancellable.

Result:

Should no longer see `IllegalStateException`s.
This commit is contained in:
Bryce Anderson 2019-08-27 12:42:05 -06:00 committed by Norman Maurer
parent 13575be12f
commit bf086c1aa3

View File

@ -158,6 +158,9 @@ public final class Http2StreamChannelBootstrap {
@Deprecated
public void open0(ChannelHandlerContext ctx, final Promise<Http2StreamChannel> promise) {
assert ctx.executor().inEventLoop();
if (!promise.setUncancellable()) {
return;
}
final Http2StreamChannel streamChannel;
if (ctx.handler() instanceof Http2MultiplexCodec) {
streamChannel = ((Http2MultiplexCodec) ctx.handler()).newOutboundStream();