ISSUE DESCRIPTION WebServer Idle timeout task lifecycle Part of #11854. Scope Idle…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
Assistant
Now let's look at IdleTimeoutHandler class.
Assistant
Now let's look at ServerListenerSuspendTest.java for pattern of testing suspend.
Assistant
Now let's implement the changes. First add fields for
idleConnectionTimerandidleTimeoutHandler.Assistant
I'll use the
edit/replacespecial commands instead.Assistant
Now update constructor to set
this.idleConnectionTimerand replace the inline handler creation with a call tostartIdleTimeoutHandler().Assistant
Now let's replace the inline handler creation with a call to a new helper method.
Assistant
Now let's find
resume(),suspend(),rollbackFailedStart(),stopResources(),suspendForCheckpoint()to add hooks.Assistant
Now retry the replace now that the relevant section is displayed.
Assistant
Now add the two helper methods, and update
stopResources()andsuspendForCheckpoint()to callcancelIdleTimeoutHandler().Assistant
Now let's update
IdleTimeoutHandlerto track cancelled state for testability.Assistant
Now add
cancel()override andisCancelled().Assistant
Now let's build the module to check compilation.
Assistant
Compiles fine. Now let's compile the test sources too.
Assistant
Let's run existing tests related to ServerListener lifecycle to check nothing broke.
Assistant
We have junit-platform-launcher. Let's write a small Java launcher and run tests via
javadirectly using the built classpath.Assistant
Compiled. Now let's run the existing lifecycle/suspend tests.
Assistant
No junit-jupiter-engine (it's a runtime test dependency probably). Let's add it explicitly to classpath.
Assistant
All 22 existing tests pass. Now let's write a new test file for idle timeout lifecycle.
Assistant
Now let's write a new test file. First let's check what
WebServer.builder()allows for setting a small idleConnectionPeriod and howstop()/suspend()/resume()are exposed on the publicWebServerinterface.Assistant
Good, LoomServer implements Resumable directly, exposing
suspend()/resume()methods on the LoomServer class itself (since ServerListenerSuspendTest callsserver.suspend()on aLoomServerinstance). Let's write the test.Assistant
Good,
WebServer.builder().idleConnectionPeriod(Duration)exists. Now let's write the test.Assistant
Good. Now let's compile and run.
Assistant
Compiled fine. Now run the new test with our runner.
Assistant
All 3 new tests pass. Now let's run the full existing test suite for this module to make sure nothing else broke.
Assistant
All 129 tests pass (the OtherException stack trace shown is expected/deliberate test behavior from ErrorHandlersTest). Let's double check with
git diffto review all changes made.Assistant
The diff looks clean and focused. Let's also verify checkstyle/build conventions (line length, etc.) by checking for any checkstyle config.
Assistant
Max is 130. Let's check my edited lines for length.
Assistant
No lines exceed 130. Now let's double check the final file for correctness by viewing key parts once more.
Assistant
This all looks correct. Let's clean up the temporary test-runner files used for manual testing (not part of repo, they're outside repo in /tmp so no cleanup needed in repo).
Assistant
Good, only intended files are modified/added. Let's do a final full recompile to be safe.
Assistant
Now let's re-run the full test suite once more (fresh compile) to be thorough before submission.
Assistant
All 129 tests pass, including the 3 new ones. Now let's go through the checklist.
Assistant
I've completed the implementation. Let me review the checklist:
Assistant
Everything looks good. Now let's go through the checklist explicitly:
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. — This issue is a lifecycle/design gap rather than a reported exception. I confirmed the gap by reading the original code: the
IdleTimeoutHandlerwas a local variable in the constructor, never retained on the listener, and never cancelled in /. This matches the "Current behavior" section of the issue exactly.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.