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
Let me start by exploring the repository structure and understanding the codebase.
Assistant
I need to make single tool calls. Let me start by exploring the repository structure.
Assistant
Let me see the middle part of the file that was truncated, particularly the stop, suspend, and checkpoint methods.
Assistant
Now let me look at the existing test for reference patterns.
Assistant
Let me find where ServerListener is constructed and where the idleConnectionTimer comes from.
Assistant
Assistant
Let me look at how existing tests test the listener lifecycle (suspend/resume) to understand test seams.
Assistant
Let me look at LoomServer's stop/suspend/resume methods and the listener accessors.
Assistant
Now let me look at the
stopListenersmethod andidleConnectionTimercancellation.Assistant
Let me look at the ListenerConfig for idleConnectionTimeout and idleConnectionPeriod.
Assistant
Let me check the WebServer builder/build and start to confirm the returned type.
Assistant
Now I have a full understanding. Let me implement the changes. First, let me update
IdleTimeoutHandler.javato add cancellation tracking.Assistant
Now let me add the
cancel()override andcancelled()accessor at the end of the file.Assistant
Now let me update
ServerListener.java. First, add the fields.Assistant
Now let me add the fields for the timer and the idle timeout handler.
Assistant
Now let me update the constructor's idle timeout handling. Let me view the relevant section.
Assistant
Now let me find the
serverThreadState()method to add theidleTimeoutHandler()accessor nearby.Assistant
Now let me add the
cancelIdleTimeout()call tostopResources()at the start.Assistant
Now let me add
cancelIdleTimeout()tosuspendForCheckpoint()at the start.Assistant
Let me view the rest of
startItto find where to addstartIdleTimeout().Assistant
I'll add the
startIdleTimeout()call right beforeserverThread.start();. Let me edit that line.Assistant
Now let me add
cancelIdleTimeout()torollbackFailedStart()to handle the case where startup was cancelled after the idle timeout was started.Assistant
Now let me add the
idleTimeoutHandler(String socketName)accessor toLoomServer.java.Assistant
Now let me check the build setup to understand how to compile and run tests.
Assistant
Now let me create the test file. Let me create
ServerListenerIdleTimeoutTest.javain the test directory.Assistant
Let me check what
LoomServer.stop()does when already stopped, to ensure repeated stop is safe.Assistant
Let me check
LoomServer.suspend()andresume()to verify the suspend/resume test flow.Assistant
Let me verify the build compiles. Let me check the Java/Maven setup.
Assistant
Let me try to compile the webserver module to verify the changes compile.
Assistant
The release version is 26 but the JDK is 25. Let me check available JDKs.
Assistant
The project requires Java 26 but only Java 25 is available. Let me try compiling with an override to at least verify my changes compile.
Assistant
Compilation seems to have succeeded. Let me confirm the test class was compiled.
Assistant
All classes compiled. Now let me run the new test to verify it passes.
Assistant
The surefire provider isn't available offline. Let me try running online to download it.
Assistant
The output is truncated. Let me see the full test result. It seems to have run but the output was cut at the warnings. Let me run again and capture the BUILD SUCCESS / FAILURE line and test counts.
Assistant
Both tests pass. Now let me run the existing related tests to ensure I didn't break anything.
Assistant
All existing tests pass. Let me also run the resource-limits module tests (which include the IdleTimeoutTest).
Assistant
The resource-limits module needs sibling modules installed in the local repo, which is an environment limitation unrelated to my changes. Let me run a broader set of the webserver module's own tests to ensure nothing broke.
Assistant
All 128 tests in the webserver module pass. Let me review the full diff to make sure everything is clean.
Assistant
Let me check git status to ensure the new test file will be included in the submission.
Assistant
The new test file is untracked, and
git diffdoesn't show untracked files. To ensure it's included in the submission (which usesgit diff), I'll mark it as intent-to-add withgit add -N, which makes it appear ingit diffwhile keeping changes unstaged.Assistant
Let me view the final test file to confirm it's clean.
Assistant
Everything looks clean and complete. Let me do a final verification that the full diff (including the new test) is correct.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.