Skip to content

FlowControlHandler: Fix autoRead behavior#16912

Merged
chrisvest merged 1 commit into
netty:4.1from
chrisvest:4.1-backport-flowcontroller-autoread
Jun 5, 2026
Merged

FlowControlHandler: Fix autoRead behavior#16912
chrisvest merged 1 commit into
netty:4.1from
chrisvest:4.1-backport-flowcontroller-autoread

Conversation

@chrisvest
Copy link
Copy Markdown
Member

Motivation:

The current implementation still has two problems:

  1. The handling of auto-read and self-triggered channelReadComplete events is hidden inside helper methods, making the control flow harder to follow and reason about.

  2. When auto-read is enabled, FlowControlHandler should behave as if it is not present in the pipeline. However, the current implementation violates this contract:

    1. read() does not always delegate to ctx.read() when auto-read is enabled.
    2. channelReadComplete() does not always propagate channelReadComplete when auto-read is enabled.
    3. When all reads are satisfied, FlowControlHandler may self-fire channelReadComplete even though it needs to wait for upstream firing channelReadComplete when auto-read is enabled.

Modification:

  1. Moved auto-read handling into the top-level control flow, making case-handling explicit.
  2. Fixed all cases where FlowControlHandler deviated from transparent behavior when auto-read is enabled.

Result:

  1. With auto-read enabled, FlowControlHandler now behaves transparently and preserves the expected channelReadComplete propagation semantics.
  2. The control flow is easier to understand and reason about.

Motivation:

The current implementation still has two problems:

1. The handling of auto-read and self-triggered channelReadComplete events is hidden inside helper methods, making the control flow harder to follow and reason about.
2. When auto-read is enabled, FlowControlHandler should behave as if it is not present in the pipeline. However, the current implementation violates this contract:

   1. read() does not always delegate to ctx.read() when auto-read is enabled.
   2. channelReadComplete() does not always propagate channelReadComplete when auto-read is enabled.
   3. When all reads are satisfied, FlowControlHandler may self-fire channelReadComplete even though it needs to wait for upstream firing channelReadComplete when auto-read is enabled.

Modification:

1. Moved auto-read handling into the top-level control flow, making case-handling explicit.
2. Fixed all cases where FlowControlHandler deviated from transparent behavior when auto-read is enabled.

Result:

1. With auto-read enabled, FlowControlHandler now behaves transparently and preserves the expected channelReadComplete propagation semantics.
2. The control flow is easier to understand and reason about.
@chrisvest chrisvest added this to the 4.1.136.Final milestone Jun 4, 2026
@chrisvest chrisvest enabled auto-merge (squash) June 4, 2026 19:57
@chrisvest chrisvest disabled auto-merge June 4, 2026 22:36
@chrisvest chrisvest merged commit d2bbe5e into netty:4.1 Jun 5, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants