shinseongsu opened a new pull request, #951: URL: https://github.com/apache/httpcomponents-client/pull/951
Follow-up to #943, the same overwrite in `MinimalHttpAsyncClient#leaseEndpoint`. When the pool has room, `manager.lease()` completes synchronously. The lease callback starts the connect and calls `resultFuture.setDependency(connectFuture)` before `lease()` returns, and the `resultFuture.setDependency(leaseFuture)` right after it replaces that with the lease, which is already done. Cancelling the request during the connect doesn't reach the connect. When the connect finishes, `resultFuture.completed()` is ignored because the future is already cancelled, so the endpoint is never released. Every such cancel takes one connection out of the pool for good. The change uses the same `ComplexCancellable` holder as #943. ### How I tested it `HttpAsyncClients.createMinimal(cm)`, max 20 per route, against a local TLS server that finishes the handshake after 1 s. 20 requests, each cancelled after 300 ms, then one more request with a 2 s connection request timeout. | | master | patched | |---|---|---| | pool 3 s after the last cancel | leased: 20, available: 0 | leased: 0 | | next request | no response within 10 s | 200 in 1.06 s | With this change alone the cancelled TLS sessions still stay open until their handshake ends. That part is #950. `TestMinimalHttpAsyncClient#testCancellationReachesConnectAfterSynchronousLease` fails on master and passes with the change. httpclient5 `verify`: 1161 tests, 0 failures. httpclient5-testing async tests: 407, 0 failures. While testing I also noticed that cancelling a `MinimalHttpAsyncClient` request after the exchange has started doesn't abort it. `execute()` only links the cancellable to the lease future, which is complete by then, so the server still sends the response 3 s later and the connection goes back to the pool. `HttpAsyncClient` closes the connection in the same case. Is that intended for the minimal client, or should I look into it? -- 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]
