public static void main(final String[] args) throws Exception {
        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
            final HttpHost target = new HttpHost("http", "httpbin.org");
            final HttpGet httpget = new HttpGet("/get");

            System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());

            // Make sure the response is always closed at the end of the message exchange
            try (ClassicHttpResponse response = httpclient.executeOpen(target, httpget, null)) {
                System.out.println("----------------------------------------");
                System.out.println(httpget + "->" + new StatusLine(response));
                // Make sure the response content entity has been fully consumed
                // in order to ensure the underlying connection can be re-used for
                // subsequent requests
                EntityUtils.consume(response.getEntity());
            }
        }
    }
This example demonstrates how to ensure the release of the underlying HTTP connection back to
the connection manager in case of a manual processing of HTTP responses.
httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionRelease.java