From d373fe2e378e3797d1b64f255f281f0b1f41cede Mon Sep 17 00:00:00 2001 From: Konstantine Karantasis Date: Tue, 20 Feb 2018 17:15:31 +0000 Subject: [PATCH] MINOR: Redirect response code in Connect's RestClient to logs instead of stdout Sending the response code of an http request issued via `RestClient` in Connect to stdout seems like a unconventional choice. This PR redirects the responds code with a message in the logs at DEBUG level (usually the same level as the one that the caller of `RestClient.httpRequest` uses. This fix will also fix system tests that broke by outputting this response code to stdout. Author: Konstantine Karantasis Reviewers: Randall Hauch , Damian Guy Closes #4591 from kkonstantine/MINOR-Redirect-response-code-in-Connect-RestClient-to-logs-instead-of-stdout (cherry picked from commit b79e11bb511e259c8187d865761c3b448391603f) Signed-off-by: Damian Guy --- .../org/apache/kafka/connect/runtime/rest/RestClient.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java index d500ad27be0..15e8418a30c 100644 --- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java +++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java @@ -82,12 +82,14 @@ public class RestClient { req.method(method); req.accept("application/json"); req.agent("kafka-connect"); - req.content(new StringContentProvider(serializedBody, StandardCharsets.UTF_8), "application/json"); + if (serializedBody != null) { + req.content(new StringContentProvider(serializedBody, StandardCharsets.UTF_8), "application/json"); + } ContentResponse res = req.send(); int responseCode = res.getStatus(); - System.out.println(responseCode); + log.debug("Request's response code: {}", responseCode); if (responseCode == HttpStatus.NO_CONTENT_204) { return new HttpResponse<>(responseCode, convertHttpFieldsToMap(res.getHeaders()), null); } else if (responseCode >= 400) {