StreamBufferingEncoder extends DecoratingHttp2ConnectionEncoder { public int numBufferedStreams() { return pendingStreams.size(); } 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 receivingGoAwayFailsBufferedStreams() { encoder.writeSettingsAck(ctx, newPromise()); setMaxConcurrentStreams(5); int streamId = 3; List<ChannelFuture> futures = new ArrayList<ChannelFuture>(); for (int i = 0; i < 9; i++) { futures.add(encoderWriteHeaders(streamId, newPromise())); streamId += 2; } assertEquals(4, encoder.numBufferedStreams()); connection.goAwayReceived(11, 8, EMPTY_BUFFER); assertEquals(5, connection.numActiveStreams()); int failCount = 0; for (ChannelFuture f : futures) { if (f.cause() != null) { failCount++; } } assertEquals(9, failCount); assertEquals(0, encoder.numBufferedStreams()); }