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 seams, then make the smallest lifecycle-focused change and run the relevant webserver tests.
- Assistant
rgisn’t installed here, so I’m switching to repository-localgrep/find. The handler is currently created and started in the constructor, confirming it is neither retained nor aligned with actual listener startup. - Assistant
The lifecycle has one important wrinkle: a
TimerTaskcannot be restarted after cancellation. I’m checking suspend/resume ownership now so the fix cancels on suspend and creates a fresh handler on resume, while keeping ordinary stop and failed-start cleanup idempotent. - Assistant
The focused implementation is in place: the listener now owns the timer and current task, schedules a fresh task only after binding during startup/resume, and cancels-and-clears it in stop, suspend, and failed-start cleanup. The tests capture the actual scheduled
TimerTask, so cancellation is verified immediately without timing sleeps. - Assistant
The test run is blocked by the workspace JDK: this checkout compiles with
--release 26, while the active Java installation is older. I’ll still run the repository’s static checks where possible and inspect the configured toolchains/available JDKs before concluding verification. - Assistant
Static validation passes, and the only remaining verification gap is execution under Java 26. I’m doing a final diff/lifecycle review now, including the already-cancelled task path and suspend/resume replacement behavior.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.