title: Right way to close CloseableHttpResponse/CloseableHttpClient
body: <p>I'm using CloseableHttpResponse (from apache-httpclient-4.5.3) and I'm not sure I'm using it right, I saw an <a href="https://stackoverflow.com/questions/44469833/why-does-apache-closeablehttpresponse-not-consume-the-entity-on-close">answer with no votes</a> to use <code>EntityUtils.consume</code> on finally:</p>
  <blockquote>
  <pre><code>CloseableHttpResponse response1 = httpclient.execute(httpGet);
  
  try {
  
   System.out.println(response1.getStatusLine());
  
  } finally {
  
   EntityUtils.consume(response1.getEntity());
  </code></pre>
  </blockquote>
  <p><code>CloseableHttpClient</code> is abstract and has no close method to call although in this <a href="https://stackoverflow.com/questions/21574478/what-is-the-difference-between-closeablehttpclient-and-httpclient-in-apache-http">answer</a> it's used:</p>
  <pre><code>CloseableHttpResponse response = httpclient.execute(httpget);
  try {
      //do something
  } finally {
      response.close();
  }
  </code></pre>
  <p>Currently I'm using try with resources for <code>CloseableHttpClient</code> and <code>CloseableHttpResponse</code> inside of send method.</p>
  <p>Am I not missing any resource open or using it in a wrong way?</p>
  <pre><code>private CloseableHttpResponse send()
              throws URISyntaxException, UnsupportedEncodingException, IOException, ClientProtocolException {
          URIBuilder uriBuilder = new URIBuilder(BASE_URL);
          HttpHost target = new HttpHost(uriBuilder.getHost(), uriBuilder.getPort(), uriBuilder.getScheme());
          HttpPost post = new HttpPost(uriBuilder.build());
          try (CloseableHttpClient httpClient = HttpClients.custom().build(); CloseableHttpResponse response = httpClient.execute(target, post)) {            
              return response;
          }
      
  </code></pre>