s/elasticsearchResponse/response
This commit is contained in:
parent
853ea9385b
commit
cbdffc7965
|
@ -156,35 +156,35 @@ public final class RestClient implements Closeable {
|
||||||
request.reset();
|
request.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseableHttpResponse response;
|
CloseableHttpResponse httpResponse;
|
||||||
try {
|
try {
|
||||||
response = client.execute(host, request);
|
httpResponse = client.execute(host, request);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
RequestLogger.log(logger, "request failed", request, host, e);
|
RequestLogger.log(logger, "request failed", request, host, e);
|
||||||
onFailure(host);
|
onFailure(host);
|
||||||
lastSeenException = addSuppressedException(lastSeenException, e);
|
lastSeenException = addSuppressedException(lastSeenException, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Response elasticsearchResponse = new Response(request.getRequestLine(), host, response);
|
Response response = new Response(request.getRequestLine(), host, httpResponse);
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
if (statusCode < 300 || (request.getMethod().equals(HttpHead.METHOD_NAME) && statusCode == 404) ) {
|
if (statusCode < 300 || (request.getMethod().equals(HttpHead.METHOD_NAME) && statusCode == 404) ) {
|
||||||
RequestLogger.log(logger, "request succeeded", request, host, response);
|
RequestLogger.log(logger, "request succeeded", request, host, httpResponse);
|
||||||
onSuccess(host);
|
onSuccess(host);
|
||||||
return elasticsearchResponse;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
RequestLogger.log(logger, "request failed", request, host, response);
|
RequestLogger.log(logger, "request failed", request, host, httpResponse);
|
||||||
String responseBody;
|
String responseBody;
|
||||||
try {
|
try {
|
||||||
if (elasticsearchResponse.getEntity() == null) {
|
if (response.getEntity() == null) {
|
||||||
responseBody = null;
|
responseBody = null;
|
||||||
} else {
|
} else {
|
||||||
responseBody = EntityUtils.toString(elasticsearchResponse.getEntity());
|
responseBody = EntityUtils.toString(response.getEntity());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
elasticsearchResponse.close();
|
response.close();
|
||||||
}
|
}
|
||||||
ResponseException responseException = new ResponseException(
|
ResponseException responseException = new ResponseException(
|
||||||
elasticsearchResponse, responseBody);
|
response, responseBody);
|
||||||
lastSeenException = addSuppressedException(lastSeenException, responseException);
|
lastSeenException = addSuppressedException(lastSeenException, responseException);
|
||||||
//clients don't retry on 500 because elasticsearch still misuses it instead of 400 in some places
|
//clients don't retry on 500 because elasticsearch still misuses it instead of 400 in some places
|
||||||
if (statusCode == 502 || statusCode == 503 || statusCode == 504) {
|
if (statusCode == 502 || statusCode == 503 || statusCode == 504) {
|
||||||
|
|
Loading…
Reference in New Issue