Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267140

Support closing the HttpClient by making it auto-closable

    XMLWordPrintable

Details

    • b18

    Description

      A DESCRIPTION OF THE PROBLEM :
      The documentation for java.net.http.HttpClient does not explain if / when underlying resources are closed. This is causing confusion (see https://stackoverflow.com/q/53919721 ) because users are normally used to closing the client when they are done with their HTTP requests, see for example:
      - Apache HttpClient: https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/classic/CloseableHttpClient.html
      - Ktor: https://api.ktor.io/ktor-client/ktor-client-core/io.ktor.client/-http-client/close.html

      Therefore it would be good to explain in the HttpClient documentation when resources are closed.
      Alternatively / additionally (depending on how reliable the current implementation is), it might be good to provide a method to close the HttpClient manually (e.g. by implementing Closeable).


      Attachments

        Issue Links

          Activity

            People

              dfuchs Daniel Fuchs
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: