public void returnClient(CloseableHttpResponse resp) {
        try { 
            if (resp != null) {
                EntityUtils.consume(resp.getEntity());
            }
        } catch (IOException ex) {
            //TODO: Could not consume response completely. This is serious because the client will not be returned back to pool.
            log.error("Error returning client to pool {}", ExceptionUtils.getStackTrace(ex));
        }
    }
public void returnClient ( CloseableHttpResponse resp ) { try { if ( resp != null ) { EntityUtils . consume ( resp . getEntity ( ) ) ; } } catch ( IOException ex ) { log . error ( "Error returning client to pool {}" , ExceptionUtils . getStackTrace ( ex ) ) ; } }
This ensures the response body is completely consumed and hence the HttpClient
object will be return back to the pool successfully.
@param resp