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 tests, then make the smallest state/cleanup change and run focused WebServer tests.
- Assistant
The handler currently starts in the constructor, before listener startup completes. I’m tracing stop, suspend/checkpoint, and failed-start rollback so cancellation lands in the shared cleanup path without changing transport behavior.
- Assistant
The focused design is to keep the shared
Timer, create a freshIdleTimeoutHandlerfor each start/resume, and atomically detach/cancel it in stop, suspend, and failed-start cleanup. A package-private timer-injection constructor will let tests observe cancellation immediately, with no waiting. - Assistant
The code path is implemented. The first test run is blocked by Maven targeting Java 26 while the active JDK is older; I’m checking the installed toolchains, then I’ll still validate compilation/style as far as this workspace permits.
- Assistant
The focused tests now pass under the installed Java 25 by overriding the repository’s Java 26 target. They confirm immediate cancellation on both stop and suspend and safe repeated stop cleanup; I’m running the surrounding listener lifecycle suites for regressions.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.