From 1932f6bc7c4c5d77f79ad27320e3dcdc3162ccfc Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 14 Jun 2016 13:45:38 +0200 Subject: [PATCH] Rename RequestLogger#log methods to distinguish between the two One method is to log a request that yielded a response, the other one for a failed request --- .../main/java/org/elasticsearch/client/RequestLogger.java | 4 ++-- .../src/main/java/org/elasticsearch/client/RestClient.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/org/elasticsearch/client/RequestLogger.java b/client/src/main/java/org/elasticsearch/client/RequestLogger.java index c08e0c69941..7268a449981 100644 --- a/client/src/main/java/org/elasticsearch/client/RequestLogger.java +++ b/client/src/main/java/org/elasticsearch/client/RequestLogger.java @@ -53,7 +53,7 @@ final class RequestLogger { /** * Logs a request that yielded a response */ - static void log(Log logger, String message, HttpUriRequest request, HttpHost host, HttpResponse httpResponse) { + static void logResponse(Log logger, String message, HttpUriRequest request, HttpHost host, HttpResponse httpResponse) { if (logger.isDebugEnabled()) { logger.debug(message + " [" + request.getMethod() + " " + host + request.getRequestLine().getUri() + "] [" + httpResponse.getStatusLine() + "]"); @@ -81,7 +81,7 @@ final class RequestLogger { /** * Logs a request that failed */ - static void log(Log logger, String message, HttpUriRequest request, HttpHost host, IOException e) { + static void logFailedRequest(Log logger, String message, HttpUriRequest request, HttpHost host, IOException e) { logger.debug(message + " [" + request.getMethod() + " " + host + request.getRequestLine().getUri() + "]", e); if (logger.isTraceEnabled()) { String traceRequest; diff --git a/client/src/main/java/org/elasticsearch/client/RestClient.java b/client/src/main/java/org/elasticsearch/client/RestClient.java index b871e2e1346..b2bd6030681 100644 --- a/client/src/main/java/org/elasticsearch/client/RestClient.java +++ b/client/src/main/java/org/elasticsearch/client/RestClient.java @@ -160,7 +160,7 @@ public final class RestClient implements Closeable { try { httpResponse = client.execute(host, request); } catch(IOException e) { - RequestLogger.log(logger, "request failed", request, host, e); + RequestLogger.logFailedRequest(logger, "request failed", request, host, e); onFailure(host); lastSeenException = addSuppressedException(lastSeenException, e); continue; @@ -168,11 +168,11 @@ public final class RestClient implements Closeable { Response response = new Response(request.getRequestLine(), host, httpResponse); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode < 300 || (request.getMethod().equals(HttpHead.METHOD_NAME) && statusCode == 404) ) { - RequestLogger.log(logger, "request succeeded", request, host, httpResponse); + RequestLogger.logResponse(logger, "request succeeded", request, host, httpResponse); onSuccess(host); return response; } - RequestLogger.log(logger, "request failed", request, host, httpResponse); + RequestLogger.logResponse(logger, "request failed", request, host, httpResponse); String responseBody; try { if (response.getEntity() == null) {