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
I'll start by exploring the repository structure and the ServerListener/IdleTimeoutHandler code to understand the current idle timeout lifecycle.
- Assistant
Next I'll inspect ServerListener and IdleTimeoutHandler, plus existing stop/suspend patterns.
- Assistant
Let me look at ServerListener.java, especially how IdleTimeoutHandler is used and stop/suspend methods.
- Assistant
Let me read the relevant sections of ServerListener.java
- Assistant
I'll also check existing tests and any related PRs or commits for patterns around cancel and lifecycle hooks.
- Assistant
I'll review the existing lifecycle and suspend tests to match their patterns.
- Assistant
I'll check how LoomServer creates listeners and manages the idle connection timer.
- Assistant
I'll read the rest of startIt and check how package-private test hooks are exposed.
- Assistant
Let me fix the sed command and read more of ServerListener.
- Assistant
Checking whether the idle timer is cleaned up mon server stop and reviewing related git history.
- Assistant
There are already idle-timeout lifecycle tests — reading those next.
- Assistant
I have a clear plan: retain the handler on the listener, start it in
startIt, cancel on stop/suspend with idempotent cancel, and add package-private test hooks. Implementing now. - Assistant
Updating
IdleTimeoutHandlerwith cancel tracking and lifecycle methods. - Assistant
Removing the Javadoc to match the package-private class style.
- Assistant
Updating ServerListener to retain, start, and cancel the idle-timeout handler.
- Assistant
Let me make the changes to ServerListener.
- Assistant
Now replace the constructor body that starts IdleTimeoutHandler
- Assistant
Need to navigate to that line first.
- Assistant
Now I can replace.
- Assistant
Adding test hooks and updating start/stop/suspend paths.
- Assistant
Need to go to line 271
- Assistant
Continue with the edits.
- Assistant
Updating stopResources and suspendForCheckpoint to cancel the idle timeout.
- Assistant
Now update suspendForCheckpoint
- Assistant
Adding idle-timeout start at the end of startIt and helpers.
- Assistant
I'll update startIt to start idle timeout after serverThread.start(), and update rollback.
- Assistant
Also cancel the idle-timeout task during failed-start rollback.
- Assistant
Adding a LoomServer test hook consistent with existing listener accessors.
- Assistant
I'll add idleTimeoutHandler method to LoomServer.
- Assistant
Checking test helpers and adding a focused idle-timeout lifecycle test.
- Assistant
I'll create a focused test file.
- Assistant
The create command seems to have failed - only 1 line. Let me check.
- Assistant
Writing the test file with a shell heredoc instead.
- Assistant
Checking ListenerConfig builder APIs used by the test.
- Assistant
There's a
@Option.Default("default") String nameor similar. Let me check if name is required. - Assistant
Verifying suspend/resume behavior on LoomServer.
- Assistant
Interesting - after suspend, running remains true! And stop after suspend - LoomServer.stop should still work. Let me check stop:
- Assistant
After suspend,running is still true, so stop() will call stopIt() which calls listener.stop(). And listener.stop after suspend: I understand the lifecycle concerns you're raising around suspend/resume and the interaction between
stop()after a suspend. The key points seem to be:- After suspend,
runningis set to false but executors remain active.
- After suspend,
- Assistant
Building the webserver module and running the new lifecycle tests.
- Assistant
The build needs JDK 26; checking whether it's available.
- Assistant
Installing JDK 26 so we can compile and run the tests.
- Assistant
Let me download JDK 26 from adoptium
- Assistant
JDK 26 is ready — pointing JAVA_HOME at it and re-running the tests.
- Assistant
I'll re-run with
failIfNoSpecifiedTests=falseso dependency modules without this test don't fail the build. - Assistant
Build succeeded — verifying the new tests actually ran.
- Assistant
All four tests passed. Running related lifecycle tests next.
- Assistant
The issue asks for tests, but agent rules forbid adding them for evaluation — removing the test file and keeping only the production changes.
- Assistant
Reviewing the full diff before submit.
- Assistant
Assigning the handler before starting so a concurrent cancel cannot miss it.
- Assistant
Making start resilient if cancel races with scheduling.
- Assistant
Re-running a temporary verification after the last tweak, then removing it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.