title: When to call close on CloseableHttpClient instnances
body: <p>Following the documentation at <a href="https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html" rel="nofollow noreferrer">https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html</a></p>
  
  <pre><code>2.3.4. Connection manager shutdown
  
  When an HttpClient instance is no longer needed and is about to go out of scope it is important to shut down its connection manager to ensure that all connections kept alive by the manager get closed and system resources allocated by those connections are released.
  
  CloseableHttpClient httpClient = &lt;...&gt;
  httpClient.close();
  </code></pre>
  
  <p>My confusion is about conflating the the instance going out of scope and needing to shutdown the connection manager.</p>
  
  <p>In my use case, I am using the PoolingConnection so I want to keep the connections open, but of course return them back to the pool.</p>
  
  <p>In my client code I have</p>
  
  <pre><code>ResponseHandler&lt;Integer&gt; rh = new ResponseHandler&lt;Integer&gt;()
   .... elided ....
  CloseableHttpClient httpclient = this.httpClientBuilder.build();
  Integer statusCode = httpclient.execute(httpPost, rh);
  </code></pre>
  
  <p>My understanding from the docs is that that the useage of ResponseHandler takes care of return the lease</p>
  
  <pre><code>When using a ResponseHandler, HttpClient will automatically take care of ensuring release of the connection back to the connection manager 
  </code></pre>