jira-importer opened a new issue, #1326:
URL: https://github.com/apache/httpcomponents-core/issues/1326

   **[Benjamin 
Peterson](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=benjaminp)**
 opened 
**[HTTPCORE-795](https://issues.apache.org/jira/browse/HTTPCORE-795?redirect=false)**
 and commented
   
   Consider `InternalExecRuntime.acquireEndpoint`:
   
   ```java
   try {
       final ConnectionEndpoint connectionEndpoint = 
connRequest.get(connectionRequestTimeout);
   } catch (final TimeoutException ex) {
       connRequest.cancel();
       throw new ConnectionRequestTimeoutException(ex.getMessage());
   } catch (final InterruptedException interrupted) {
       connRequest.cancel();
       Thread.currentThread().interrupt();
       throw new RequestFailedException("Request aborted", interrupted);
   }
   ```
   
   Consider this order of operations:
   1. The thread blocked in `codeRequest.get` is interrupted or times out.
   2. The connection pool completes the future with a connection.
   3. The interrupted thread starts propagating the `InterruptedException` or 
`TimeoutException`. When it reaches the `catch` blocks, it will call 
`connRequest.cancel()`. But cancelation will do nothing because the connection 
pool already completed the future. The connection will leak.
   
   The window may be narrow, but it's certainly a possibility if heavy load 
means the blocked thread is delayed in being scheduled to propagate the 
`InterruptedException` or `TimeoutException`.
   
   
   ---
   
   **Attachments:**
   - 
[HttpGetExample.java](https://issues.apache.org/jira/secure/attachment/13081061/HttpGetExample.java)
 (_2.87 kB_)
   - 
[HttpGetExample2.java](https://issues.apache.org/jira/secure/attachment/13081064/HttpGetExample2.java)
 (_3.28 kB_)
   - 
[TimeoutLeakExample.java](https://issues.apache.org/jira/secure/attachment/13081067/TimeoutLeakExample.java)
 (_3.24 kB_)
   
   **Backported to:** 
[5.4.3](https://github.com/apache/httpcomponents-core/milestone/106?closed=1)
   


-- 
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]

Reply via email to