在此代码段中
public <T extends JestResult> T execute(Action<T> clientRequest) throws IOException {
HttpUriRequest request = prepareRequest(clientRequest);
HttpResponse response = httpClient.execute(request);
return deserializeResponse(response, request, clientRequest);
}
private <T extends JestResult> T deserializeResponse(HttpResponse response, Action<T> clientRequest) throws IOException {
StatusLine statusLine = response.getStatusLine();
return clientRequest.createNewElasticSearchResult(
response.getEntity() == null ? null : EntityUtils.toString(response.getEntity()),
statusLine.getStatusCode(),
statusLine.getReasonPhrase(),
gson
);
}
在我们收到回复后,我们不应该做类似的事情吗
response.close()
这个特殊的堆栈溢出线程HttpClient 4.0.1 - 如何释放连接?提到使用响应实体
EntityUtils.consume(HttpEntity)
做EntityUtils.toString(response.getEntity())
就够了吗?