Community
Participate
Working Groups
Build Identifier: Add Unit Tests for idle timeouts. Reproducible: Always
There's no maxIdleTimeout Tests for suspended asyn http requests. Add tests for maxIdleTimeout after a request has been suspended+resumed, suspended+timeout, suspended+complete. Doing this, I found out that maxIdleTimeout doesn't get reenabled after a request has been suspended. It gets disabled in AsyncHttpConnection line 59: // don't check for idle while dispatched (unless blocking IO is done). _asyncEndp.setCheckForIdle(false); And needs to be reenabled after resume/timeout/complete. I will fix it as part of this issue.
Created attachment 209021 [details] proposed patch Patch attached. Fixes maxIdleTime after suspend/resume/complete and adds tests for each case.
Created attachment 209065 [details] proposed patch - second commit
Reviewed and fixed: the 2 patches implement the right behavior and add tests to prove it.
Can you add a comment to the code to explain the line if (_request.getAsyncContinuation().isComplete() || _request.getAsyncContinuation().isInitial()) { _asyncEndp.setCheckForIdle(true); } I would expect that we should re-enable idle for all exits from handle except if the request is suspended (in which case the suspended timeout is monitoring the connection). Do you agree with that logic? If so, it would be best to rewrite that condition so that it looks like that logic. Either way, we need a comment describing the logic.
Reviewing this again I see that the logic is using the initial state to determine if the request is suspended, and then excluding the completed state from not re-initializing the idle check. This is too convoluted. I think the code should just be: // reenable idle checking unless request is suspended if(!_request.getAsyncContinuation().isAsyncStarted()) { _asyncEndp.setCheckForIdle(true); } This passes the jetty-server tests, so I've committed. Please review and if you agree then mark issue as resolved.
Hi Greg, reviewed your changes, retestet them and they're good. Like the new if/else in the finally block. The new maxIdleTests are still green. I will resolve this issue now. maxIdle is working again after resume/timeout/complete. Cheers, Thomas
Created attachment 209318 [details] Enhanced tests Better (actually working) tests.
Reopened as the new tests need to be commited, please.
Enhanced test patch has been reviewed and committed.