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 lifecycle-focused change and run the relevant webserver tests.
- Assistant
rgisn’t installed in this workspace, so I’m using targetedfind/grepinspection. The handler is currently started in the constructor, which also means lifecycle timing—not just cancellation—needs careful placement. - Assistant
The focused design is: keep the timer as listener state, create a fresh
TimerTaskon each startup/resume, and atomically detach-and-cancel it in stop, suspend, and failed-start rollback. A package-private timer-injection constructor will provide the requested deterministic test seam without adding an interface. - Assistant
The first implementation pass is in place. I’m compiling and running the focused tests now; I’ll also verify resume creates a fresh timeout task, because a cancelled
TimerTaskcannot be restarted. - Assistant
The test run is blocked by the workspace JDK: this checkout compiles with Java 26, while the active compiler is older. I’ll continue with offline/local validation and inspect installed JDKs before deciding whether compilation is possible here.
- Assistant
Production and test sources compile successfully under the installed Java 25 using the project’s release override. Test execution itself cannot start offline because the local Maven cache lacks Surefire’s JUnit platform provider; I’m completing static/style checks and a lifecycle edge-case review now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.