benmoss opened a new pull request, #1125: URL: https://github.com/apache/tomcat/pull/1125
Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=70290 ## Problem When a client drops the connection during the initial async service call and an `AsyncListener.onError()` handler then calls `AsyncContext.dispatch()`, the request can be recycled while the async state machine is still in `MUST_DISPATCH`. `onComplete()` is never called and `StandardContext.inProgressAsyncCount` is never decremented, so the count leaks by one per affected request and can prevent a graceful shutdown. This is the `MUST_DISPATCH` path left open after BZ 68227, which only added `onComplete()` handling to the `DISPATCHING` branch. ## Fix * `CoyoteAdapter.service()` now forces `ASYNC_POST_PROCESS` during cleanup for a dispatching async request as well as a completing one, matching the sibling `asyncDispatch()` path. * `AsyncStateMachine.asyncPostProcess()` now completes the lifecycle (fires `onComplete()`, decrements the count) from the `MUST_DISPATCH` branch when I/O is no longer allowed, mirroring the existing `DISPATCHING` branch. When I/O is still allowed the dispatch proceeds unchanged. ## Testing New `TestAsyncResetInProgressCount` (extends `TomcatBaseTest`) reproduces the leak deterministically (RST during the initial service window plus a dispatch from `onError()`). Before the fix it fails every round with a monotonically growing count; after the fix it passes. Verified on Linux (OpenJDK 25) and macOS. The existing `TestAsyncContext*` suite (99 tests, including the BZ 68227 regression test) passes with the change. Changelog attribution left as a placeholder for the committer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
