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