Repository: netty/netty
File: codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java (Java)

Code before:
            }
            super.setRecvByteBufAllocator(allocator);
            return this;
        }

        @Override
        public Map<ChannelOption<?>, Object> getOptions() {
            return getOptions(
                    super.getOptions(),
                    Http2StreamChannelOption.AUTO_WRITE_WINDOW_UPDATE_FRAME);
        }

        @SuppressWarnings("unchecked")
        @Override
        public <T> T getOption(ChannelOption<T> option) {
            if (option == Http2StreamChannelOption.AUTO_WRITE_WINDOW_UPDATE_FRAME) {
                return (T) Boolean.valueOf(autoFlowControl);
            }
            return super.getOption(option);
        }

        @Override
        public <T> boolean setOption(ChannelOption<T> option, T value) {
            validate(option, value);
            if (option == Http2StreamChannelOption.AUTO_WRITE_WINDOW_UPDATE_FRAME) {
                autoFlowControl = (Boolean) value;
                return true;
            }
            return super.setOption(option, value);
        }
    }

    private void maybeAddChannelToReadCompletePendingQueue() {
        if (!readCompletePending) {
            readCompletePending = true;
            addChannelToReadCompletePendingQueue();
        }
    }

    protected void flush0(ChannelHandlerContext ctx) {
        ctx.flush();
    }

    protected ChannelFuture write0(ChannelHandlerContext ctx, Object msg) {
        ChannelPromise promise = ctx.newPromise();
        ctx.write(msg, promise);
        return promise;
    }

    protected abstract boolean isParentReadInProgress();
    protected abstract void addChannelToReadCompletePendingQueue();

Review comment (suggestion):
In my minds eye, `autoFlowControl` is somewhat analogous to `autoRead`: when we switch from `autoFlowControl == false` to true, do we need to potentially send a window update? _If_ we do, it could well be a follow up.

Code after:
        Http2StreamChannelConfig(Channel channel) {
            super(channel);
        }

        @Override
        public MessageSizeEstimator getMessageSizeEstimator() {
            return FlowControlledFrameSizeEstimator.INSTANCE;
        }

        @Override
        public ChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) {
            if (!(allocator.newHandle() instanceof RecvByteBufAllocator.ExtendedHandle)) {
                throw new IllegalArgumentException("allocator.newHandle() must return an object of type: " +
                        RecvByteBufAllocator.ExtendedHandle.class);
            }
            super.setRecvByteBufAllocator(allocator);
            return this;
        }

        @Override
        public Map<ChannelOption<?>, Object> getOptions() {
            return getOptions(
                    super.getOptions(),
                    Http2StreamChannelOption.AUTO_STREAM_FLOW_CONTROL);
        }

        @SuppressWarnings("unchecked")
        @Override
        public <T> T getOption(ChannelOption<T> option) {
            if (option == Http2StreamChannelOption.AUTO_STREAM_FLOW_CONTROL) {
                return (T) Boolean.valueOf(autoStreamFlowControl);
            }
            return super.getOption(option);
        }

        @Override
        public <T> boolean setOption(ChannelOption<T> option, T value) {
            validate(option, value);
            if (option == Http2StreamChannelOption.AUTO_STREAM_FLOW_CONTROL) {
                boolean newValue = (Boolean) value;
                boolean changed = newValue && !autoStreamFlowControl;
                autoStreamFlowControl = (Boolean) value;
                if (changed) {
                    if (channel.isRegistered()) {
                        final Http2ChannelUnsafe unsafe = (Http2ChannelUnsafe) channel.unsafe();
                        if (channel.eventLoop().inEventLoop()) {