StreamBufferingEncoder extends DecoratingHttp2ConnectionEncoder { @Override public void close() { try { if (!closed) { closed = true; Http2ChannelClosedException e = new Http2ChannelClosedException(); while (!pendingStreams.isEmpty()) { PendingStream stream = pendingStreams.pollFirstEntry().getValue(); stream.close(e); } } } finally { super.close(); } } StreamBufferingEncoder(Http2ConnectionEncoder delegate);  StreamBufferingEncoder(Http2ConnectionEncoder delegate, int initialMaxConcurrentStreams); int numBufferedStreams(); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
                                      int padding, boolean endStream, ChannelPromise promise); @Override ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
                                      int streamDependency, short weight, boolean exclusive,
                                      int padding, boolean endOfStream, ChannelPromise promise); @Override ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
                                        ChannelPromise promise); @Override ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data,
                                   int padding, boolean endOfStream, ChannelPromise promise); @Override void remoteSettings(Http2Settings settings); @Override void close();  }
@Test public void closeShouldCancelAllBufferedStreams() throws Http2Exception { encoder.writeSettingsAck(ctx, newPromise()); connection.local().maxActiveStreams(0); ChannelFuture f1 = encoderWriteHeaders(3, newPromise()); ChannelFuture f2 = encoderWriteHeaders(5, newPromise()); ChannelFuture f3 = encoderWriteHeaders(7, newPromise()); encoder.close(); assertNotNull(f1.cause()); assertNotNull(f2.cause()); assertNotNull(f3.cause()); }