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

   **[Linton 
Miller](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=linton.miller)**
 opened 
**[HTTPCORE-585](https://issues.apache.org/jira/browse/HTTPCORE-585?redirect=false)**
 and commented
   
   When servicing the queue of pending lease requests, the LaxConnPool will 
lose a pending request if it can't be fulfilled from the pool.
   
    
   
   ```java
               while ((leaseRequest = pending.poll()) != null) {
                   if (leaseRequest.isDone()) {
                       continue;
                   }
                   final Object state = leaseRequest.getState();
                   final Deadline deadline = leaseRequest.getDeadline();
   
                   if (deadline.isExpired()) {
                       
leaseRequest.failed(DeadlineTimeoutException.from(deadline));
                   } else {
                       final PoolEntry<T, C> availableEntry = 
getAvailableEntry(state);
                       if (availableEntry != null) {
                           addLeased(availableEntry);
                           leaseRequest.completed(availableEntry);
                       } else if (leased.size() < max) {
                           final PoolEntry<T, C> newEntry = new 
PoolEntry<>(route, timeToLive);
                           addLeased(newEntry);
                           leaseRequest.completed(newEntry);
                       }
                       // ***** Must do something here if there was no 
connection available to fulfill the request *****
                       break;
                   }
               }
   ```
   
   The lease request is popped off the head of the queue and attempted to be 
fulfilled. In normal circumstances we'd expect this would succeed, because it's 
called from release, where we've just put a connection back in the pool. 
However, there's no guarantee some other thread hasn't jumped in and stolen 
that connection before we could grab it, so we may not be able to fulfill the 
lease request. In that case, we must put the lease request back on the pending 
queue or it will be lost, never to be completed or failed.
   
   ```java
                       final PoolEntry<T, C> availableEntry = 
getAvailableEntry(state);
                       if (availableEntry != null) {
                           addLeased(availableEntry);
                           leaseRequest.completed(availableEntry);
                       } else if (leased.size() < max) {
                           final PoolEntry<T, C> newEntry = new 
PoolEntry<>(route, timeToLive);
                           addLeased(newEntry);
                           leaseRequest.completed(newEntry);
                       } else {
                           pending.addFirst(leaseRequest);
                       }
                       break;
   ```
   
    
   
   
   ---
   
   **Affects:** 5.0-beta8
   
   **Remote Links:**
   - [GitHub Pull Request `#133`
   ](https://github.com/apache/httpcomponents-core/pull/133)
   


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