title: HttpClient is "reinitialized" after each 100 calls
body: <p>I have Groovy script that has to post a lot of calls to my API. I am using one http client for all calls - <a href="http://hc.apache.org/httpclient-3.x/performance.html#Reuse_of_HttpClient_instance" rel="nofollow">for best performance</a></p>
  
  <p>There my code:</p>
  
  <pre><code>httpClient = new HttpClient() 
  def start = new Date().getTime()
  def i = 0
  
  for (item in items) {
    post(item)
    def spend = new Date().getTime()- start // usual call takes 100-300 miliseconds
    start = new Date().getTime()
  
    if(spend&gt;1000){
    logger.debug i
    }
    ++i
  }
  
  def post(item){
    def httpMethod = new PostMethod(endpoint)
    httpMethod.setRequestHeader(new Header("Content-Type", "application/json"))
    httpMethod.setRequestHeader(new Header("Host", AWS.Host))
    httpMethod.setRequestHeader(new Header("x-amz-date", amzDate))
    httpMethod.setRequestHeader(new Header("Authorization", authorizationHeader))
    def requestEntity = new StringRequestEntity(item, "application/json", "UTF-8")
    httpMethod.setRequestEntity(requestEntity)
    def statusCode = httpClient.executeMethod(httpMethod)
    httpMethod.releaseConnection()
    return statusCode &gt;= 200 &amp;&amp; statusCode &lt; 300
  }
  </code></pre>
  
  <p>This code printed for me:</p>
  
  <pre><code>DEBUG: 0 : 1504 
  DEBUG: 100 : 1389
  DEBUG: 200 : 1177
  DEBUG: 400 : 1200
  DEBUG: 500 : 1058
  ...
  </code></pre>
  
  <p>As I get correct httpClient is initialize something during the first call and has to reinitialize same stuff after each 100th call.</p>
  
  <p><strong>EDIT:</strong> My code calls Amazon API gateway. When I change method to GET and call Google - this issues wasn't reproduced.</p>
  
  <p>Is it possible to avoid this reinitialization? </p>