Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1857

HttpClient falsely closes a reusable connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • None
    • None
    • None

    Description

      If you create a code with a reusable httpclient and then call execute as in the example with the following code. The http connection will be falsely closed.

      private PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
      httpClient = HttpClients.custom()
      .setConnectionManager(connectionManager)
      .build();
      
      try (CloseableHttpResponse response = httpClient.execute(new HttpGet(enetLink), context)) {
      .....
      }
      

      The reason being that we have:

      CloseableHttpResponse:
          public void close() throws IOException {
              if (this.connHolder != null) {
                  this.connHolder.close();
              }
          }
      ConnectionHolder:
          public void close() throws IOException {
              releaseConnection(false);
          }
      

      Just created the correction, which is attached as patch.

      Attachments

        1. ConnectionHolder.patch
          0.5 kB
          Rodolfo Udo Labsch

        Activity

          People

            Unassigned Unassigned
            Devilus Rodolfo Udo Labsch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: