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 4c14fa5c54
commit a89cde9475

View File

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