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 relevant ServerListener code to understand the current idle timeout handling.
- Assistant
Let me look at ServerListener.java and IdleTimeoutHandler related code.
- Assistant
rg is not found, let me use grep instead.
- Assistant
Let me read the relevant sections of ServerListener and IdleTimeoutHandler.
- Assistant
Let me read more of ServerListener around the idle timeout and stop/suspend methods.
- Assistant
Let me read more about stopResources, suspend, etc.
- Assistant
Let me continue reading suspendForCheckpoint and related cleanup code.
- Assistant
I'll look at existing tests and related lifecycle patterns for guidance.
- Assistant
I'll examine the existing lifecycle and suspend tests for patterns around idle timeout.
- Assistant
I'll inspect how tests construct ServerListener and search for any existing cancel patterns.
- Assistant
I'll check LoomServer lifecycle and package visibility patterns for testing hooks.
- Assistant
I'll inspect start failure rollback paths that may also need idle-timeout cancellation.
- Assistant
I'll check whether tests construct
ServerListenerdirectly and how hooks are exposed. - Assistant
I'll look for similar lifecycle timer patterns and the end of the lifecycle test for style.
- Assistant
I'll check how to construct the dependencies needed to unit-test ServerListener.
- Assistant
I'll inspect LoomServer for listener access patterns and package-private testing seams.
- Assistant
I'll check ListenerConfig name handling and the builder defaults.
- Assistant
I have a clear plan. Implementing idle-timeout lifecycle management and adding focused tests.
- Assistant
I need to add the AtomicBoolean import.
- Assistant
Now I'll update ServerListener to retain and manage the idle timeout task lifecycle.
- Assistant
Now replace the constructor idle timeout start code with storing the timer.
- Assistant
I need to navigate first.
- Assistant
Now I can do the replace.
- Assistant
I'll add the test hook and wire start/cancel into the lifecycle methods.
- Assistant
Need to goto the line first.
- Assistant
Let me apply multiple replacements.
- Assistant
Now update stopResources to cancel idle timeout, suspendForCheckpoint, startIt, and rollbackFailedStart.
- Assistant
Now update suspendForCheckpoint and startIt and rollbackFailedStart.
- Assistant
I'll start the idle timeout in startIt after the listener becomes running.
- Assistant
I'll add startIdleTimeout before serverThread.start() and before need to check cancel. Also hopefully after checkCancelledStartup was called before bind.
- Assistant
Add cancelIdleTimeout to rollbackFailedStart.
- Assistant
I'll add a LoomServer package-private accessor for the listener so tests can reach the idle timeout hook.
- Assistant
Need to goto first.
- Assistant
Now replace works.
- Assistant
I'll fix the comment and check stopUntilStopped helper usage for the test.
- Assistant
I introduced a weird character in the comment. Let me fix it properly.
- Assistant
Creating the focused test file.
- Assistant
The create left the file empty and I had a typo — rewriting the test correctly.
- Assistant
I'll verify the implementation and run the focused tests.
- Assistant
Need Java 26. Let me check if it's available.
- Assistant
Only Java 25 is available — I'll try overriding the release version so we can compile and run tests.
- Assistant
Let me find the version configuration.
- Assistant
Let me check bom for java version
- Assistant
I need JDK 26. Let me try to download it.
- Assistant
The download looks complete — extracting JDK 26 next.
- Assistant
JDK 26 is ready — running the focused tests next.
- Assistant
The failIfNoTests didn't work with reactor. Let me use -Dsurefire.failIfNoSpecifiedTests=false
- Assistant
Build succeeded — confirming the tests actually ran.
- Assistant
All 3 tests passed. Running related existing lifecycle and idle-timeout tests next.
- Assistant
I'll review the final diff and ensure everything looks clean.
- Assistant
The test file is untracked - checking git status.
- Assistant
Submit uses
git diff, so I'll make the new test file show up as an intent-to-add. - Assistant
Good, the test file is now a new file. Let me verify git diff includes it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.