From bf086c1aa386d0c5f2d483e8f4d2f5a53c9a8e59 Mon Sep 17 00:00:00 2001 From: Bryce Anderson Date: Tue, 27 Aug 2019 12:42:05 -0600 Subject: [PATCH] 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. --- .../netty/handler/codec/http2/Http2StreamChannelBootstrap.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java index 2c71ff89c6..0147ced137 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java @@ -158,6 +158,9 @@ public final class Http2StreamChannelBootstrap { @Deprecated public void open0(ChannelHandlerContext ctx, final Promise promise) { assert ctx.executor().inEventLoop(); + if (!promise.setUncancellable()) { + return; + } final Http2StreamChannel streamChannel; if (ctx.handler() instanceof Http2MultiplexCodec) { streamChannel = ((Http2MultiplexCodec) ctx.handler()).newOutboundStream();