WebServer Idle timeout task lifecycle Part of #11854. Scope Idle timeout tasks should be…
- User
WebServer Idle timeout task lifecycle Part of #11854.
Scope
Idle timeout tasks should be tied to listener lifecycle and cancelled when the listener stops or suspends.
Current behavior:
webserver/webserver/src/main/java/io/helidon/webserver/ServerListener.javacreates anIdleTimeoutHandleras a local value and starts it.- The listener does not retain the timeout task.
- Stop and suspend cleanup cannot cancel the idle timeout task explicitly.
Expected behavior
- Retain the idle timeout handler or task as listener state.
- Start the task with listener startup.
- Cancel the task during listener stop and suspend cleanup.
- Make cleanup idempotent so repeated stop paths do not fail because the task was already cancelled.
Implementation notes
- Keep the change limited to idle timeout lifecycle management.
- Avoid broader timer or transport refactoring unless it is required for a focused test seam.
Tests
Add focused coverage proving:
- Listener stop cancels the idle timeout task.
- Listener suspend cancels the idle timeout task.
- Repeated stop or cleanup paths remain safe.
- The test should use a small explicit hook or test timer rather than relying on long real-time waits.
Interface
No new interfaces are introduced.
- Assistant
I’ll inspect the listener lifecycle and existing timer/test infrastructure, then make the smallest state-and-cleanup change and run focused webserver tests.
- Assistant
The handler is currently started in the constructor, before listener startup, which is broader than the requested lifecycle. I’m tracing all stop, suspend, and failed-start cleanup paths now so cancellation lands in the shared cleanup seam and remains idempotent.
- Assistant
I found an existing injection seam: listeners already receive a
Timer. I’ll preserve that design, retain a fresh handler per active listener run (needed because cancelledTimerTasks cannot be restarted), cancel it in stop/suspend/failed-start cleanup, and use a recording timer that schedules far into the future so tests observe cancellation immediately without sleeping. - Assistant
The focused Maven run is blocked by the workspace JDK: the project compiles with
--release 26, but the active compiler does not support Java 26. I’m continuing with static checks and will see whether a compatible local JDK is installed; this is an environment/toolchain issue, not a test failure. - Assistant
Both production and test sources compile successfully under the locally available Java 25 override. Actual JUnit execution cannot start because the required Surefire JUnit provider is absent from the local Maven cache, and the requested offline constraint prevents fetching it. I’m doing the final diff and lifecycle-path audit now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.