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

   **[Daniel 
Jelinski](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=djelinski)**
 opened 
**[HTTPCORE-634](https://issues.apache.org/jira/browse/HTTPCORE-634?redirect=false)**
 and commented
   
   We are sporadically observing the exception mentioned in summary; while 
searching the Internet, I found [this SO 
page](https://stackoverflow.com/questions/46188047/httpclient-4-5-x-multithread-request-error-has-not-been-leased-from-this-pool)
 providing a semi-reliable reproducer. Minified form follows:
   
   ```java
   public static void main(String[] args) {
      final PoolingHttpClientConnectionManager cm = new 
PoolingHttpClientConnectionManager();
      cm.setDefaultMaxPerRoute(1);
   
      class HttpClientThead implements Runnable {
         final String reqString;
         final CloseableHttpClient httpclient1 = HttpClients.custom()
               .setConnectionManager(cm)
               .build();
   
         HttpClientThead(String reqString) {
            this.reqString = reqString;
         }
   
         public void run() {
            for (int i = 1; i <= 10; i++) {
               HttpClientContext context = HttpClientContext.create();
               try {
                  HttpGet httpget = new HttpGet(reqString);
                  CloseableHttpResponse response = httpclient1.execute(httpget, 
context);
                  response.close();
               } catch (Throwable e) {
                  e.printStackTrace();
                  System.exit(1);
               } finally {
                  cm.closeExpiredConnections();
               }
            }
         }
      }
   
      HttpClientThead t1 = new HttpClientThead("https://issues.apache.org/";);
      Thread thread1 = new Thread(t1);
      thread1.start();
      t1.run();
   }
   
   ```
   
   
   
   ---
   
   **Affects:** 4.4.11
   


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