@Override
    public ChannelFuture writeRstStream(
            ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) {
        ChannelPromise newPromise = handleOutstandingControlFrames(ctx, promise);
        if (newPromise == null) {
            return promise;
        }
        return super.writeRstStream(ctx, streamId, errorCode, newPromise);
    }
@Test
    public void testLimitRst() {
        assertFalse(encoder.writeRstStream(ctx, 1, CANCEL.code(), newPromise()).isDone());
        // The second write is always marked as success by our mock, which means it will also not be queued and so
        // not count to the number of queued frames.
        assertTrue(encoder.writeRstStream(ctx, 1, CANCEL.code(), newPromise()).isSuccess());
        assertFalse(encoder.writeRstStream(ctx, 1, CANCEL.code(), newPromise()).isDone());

        verifyFlushAndClose(0, false);

        assertFalse(encoder.writeRstStream(ctx, 1, CANCEL.code(), newPromise()).isDone());
        assertFalse(encoder.writeRstStream(ctx, 1, CANCEL.code(), newPromise()).isDone());

        verifyFlushAndClose(1, true);
    }