jira-importer opened a new issue, #921: URL: https://github.com/apache/httpcomponents-core/issues/921
**[Scott Stanton](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=stanton)** opened **[HTTPCORE-315](https://issues.apache.org/jira/browse/HTTPCORE-315?redirect=false)** and commented When using HttpAsyncRequester in combination with a BasicNIOConnPool, if the future returned from execute() is cancelled before the connection is established, then the connection will be leaked after it connects (added to the leased list after the cancelled() callbacks are invoked). The sequence that leads to this is: * AbstractNIOConnPool.requestCompleted() calls RouteSpecificPool.completed() which ultimately calls HttpAsyncRequester.completed() * HttpAsyncRequester.completed() detects that the requestFuture is done, so it attempts to release the pool entry * The pool entry hasn't been added to the leased list yet, so the release has no effect and the connection is not added to the available list * After the completed callback returns to requestCompleted(), the connection is added to the leased list. At this point, no thread is expecting to do anything further with the connection, so it is effectively lost and consuming a pool slot. I think the correct remedy is to ensure that the connection is added to the global leased list as well as the route specific leased list before the completed() callback is invoked. This should ensure that the connection is properly cleaned up. --- **Affects:** 4.2.2 **Attachments:** - [HTTPCORE-315.patch](https://issues.apache.org/jira/secure/attachment/12547481/HTTPCORE-315.patch) (_7.29 kB_) -- 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]
