You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by da...@apache.org on 2018/02/20 17:18:37 UTC

[kafka] branch 1.1 updated: MINOR: Redirect response code in Connect's RestClient to logs instead of stdout

This is an automated email from the ASF dual-hosted git repository.

damianguy pushed a commit to branch 1.1
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/1.1 by this push:
     new d373fe2  MINOR: Redirect response code in Connect's RestClient to logs instead of stdout
d373fe2 is described below

commit d373fe2e378e3797d1b64f255f281f0b1f41cede
Author: Konstantine Karantasis <ko...@confluent.io>
AuthorDate: Tue Feb 20 17:15:31 2018 +0000

    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 <ko...@confluent.io>
    
    Reviewers: Randall Hauch <rh...@gmail.com>, Damian Guy <da...@gmail.com>
    
    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 <da...@gmail.com>
---
 .../main/java/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 d500ad2..15e8418 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) {

-- 
To stop receiving notification emails like this one, please contact
damianguy@apache.org.