Skip to content

Auto-port 5.0: IdleStateHandler: reset firstWriter/ReaderIdleEvent in resetWriteTimeout/resetReadTimeout - #16987

Merged
normanmaurer merged 3 commits into
5.0from
auto-port-pr-16982-to-5.0
Jun 29, 2026
Merged

normanmaurer merged 3 commits into
5.0from
auto-port-pr-16982-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #16982 to 5.0
Cherry-picked commit: 512ba9d


Motivation

IdleStateHandler exposes two programmatic reset methods — resetWriteTimeout() and resetReadTimeout() — intended to let callers defer idle detection without performing an actual write or read. Their documented contract is to restart the
idle timer from the point of the call.

Both methods update the relevant timestamp but do not reset the corresponding "first event" flags (firstWriterIdleEvent / firstReaderIdleEvent). As a result, if a non-first idle event has already fired before the programmatic reset, the
next idle event after the reset is incorrectly reported as WRITER_IDLE_STATE_EVENT/ READER_IDLE_STATE_EVENT (first=false) instead of FIRST_WRITER_IDLE_STATE_EVENT/ FIRST_READER_IDLE_STATE_EVENT.

This is inconsistent with the writeListener path, which resets both the timestamp
and the first-event flags together.

Modifications

  • resetWriteTimeout(): add firstWriterIdleEvent = firstAllIdleEvent = true
  • resetReadTimeout(): add firstReaderIdleEvent = firstAllIdleEvent = true
  • Add IdleStateHandlerResetFlagTest with two tests that exercise the
    post-non-first-event reset sequence for both methods

Result

After calling resetWriteTimeout() or resetReadTimeout(), the next idle event correctly fires as FIRST_WRITER_IDLE_STATE_EVENT or FIRST_READER_IDLE_STATE_EVENT,consistent with what a real write or read activity would produce.


Note: the same issue exists in the 4.1 branch. Happy to provide a backport if the team considers it in scope.

…out/resetReadTimeout (#16982)

## Motivation

`IdleStateHandler `exposes two programmatic reset methods —
`resetWriteTimeout()` and `resetReadTimeout()` — intended to let callers
defer idle detection without performing an actual write or read. Their
documented contract is to restart the
idle timer from the point of the call.

Both methods update the relevant timestamp but do not reset the
corresponding "first event" flags (firstWriterIdleEvent /
firstReaderIdleEvent). As a result, if a non-first idle event has
already fired before the programmatic reset, the
next idle event after the reset is incorrectly reported as
`WRITER_IDLE_STATE_EVENT`/ `READER_IDLE_STATE_EVENT` (first=false)
instead of `FIRST_WRITER_IDLE_STATE_EVENT`/
`FIRST_READER_IDLE_STATE_EVENT`.

This is inconsistent with the writeListener path, which resets both the
timestamp
and the first-event flags together.

## Modifications

- resetWriteTimeout(): add `firstWriterIdleEvent = firstAllIdleEvent =
true`
- resetReadTimeout(): add `firstReaderIdleEvent = firstAllIdleEvent =
true`
- Add IdleStateHandlerResetFlagTest with two tests that exercise the
  post-non-first-event reset sequence for both methods

## Result

After calling `resetWriteTimeout()` or `resetReadTimeout()`, the next
idle event correctly fires as `FIRST_WRITER_IDLE_STATE_EVENT `or
`FIRST_READER_IDLE_STATE_EVENT`,consistent with what a real write or
read activity would produce.

---
Note: the same issue exists in the 4.1 branch. Happy to provide a
backport if the team considers it in scope.

Signed-off-by: husseinvr97 <[email protected]>
(cherry picked from commit 512ba9d)
@normanmaurer
normanmaurer merged commit 7922bdd into 5.0 Jun 29, 2026
11 of 13 checks passed
@normanmaurer
normanmaurer deleted the auto-port-pr-16982-to-5.0 branch June 29, 2026 12:55
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Jun 29, 2026
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.

3 participants