remove message parameter from RequestLogger methods

This prevents useless string allocation.
This commit is contained in:
javanna 2016-06-14 14:14:03 +02:00 committed by Luca Cavanna
parent 1932f6bc7c
commit cf93e904e3
2 changed files with 8 additions and 9 deletions

View File

@ -53,12 +53,11 @@ final class RequestLogger {
/**
* Logs a request that yielded a response
*/
static void logResponse(Log logger, String message, HttpUriRequest request, HttpHost host, HttpResponse httpResponse) {
static void logResponse(Log logger, HttpUriRequest request, HttpHost host, HttpResponse httpResponse) {
if (logger.isDebugEnabled()) {
logger.debug(message + " [" + request.getMethod() + " " + host + request.getRequestLine().getUri() +
"] [" + httpResponse.getStatusLine() + "]");
logger.debug("request [" + request.getMethod() + " " + host + request.getRequestLine().getUri() +
"] returned [" + httpResponse.getStatusLine() + "]");
}
if (tracer.isTraceEnabled()) {
String requestLine;
try {
@ -81,8 +80,8 @@ final class RequestLogger {
/**
* Logs a request that failed
*/
static void logFailedRequest(Log logger, String message, HttpUriRequest request, HttpHost host, IOException e) {
logger.debug(message + " [" + request.getMethod() + " " + host + request.getRequestLine().getUri() + "]", e);
static void logFailedRequest(Log logger, HttpUriRequest request, HttpHost host, IOException e) {
logger.debug("request [" + request.getMethod() + " " + host + request.getRequestLine().getUri() + "] failed", e);
if (logger.isTraceEnabled()) {
String traceRequest;
try {

View File

@ -160,7 +160,7 @@ public final class RestClient implements Closeable {
try {
httpResponse = client.execute(host, request);
} catch(IOException e) {
RequestLogger.logFailedRequest(logger, "request failed", request, host, e);
RequestLogger.logFailedRequest(logger, 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.logResponse(logger, "request succeeded", request, host, httpResponse);
RequestLogger.logResponse(logger, request, host, httpResponse);
onSuccess(host);
return response;
}
RequestLogger.logResponse(logger, "request failed", request, host, httpResponse);
RequestLogger.logResponse(logger, request, host, httpResponse);
String responseBody;
try {
if (response.getEntity() == null) {