Skip to content

Commit 488b449

Browse files
tinomthomaspedja4
authored andcommitted
BAEL 1756 (eugenp#4263) - Review comments incorporated
1 parent 1e3b3f2 commit 488b449

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎spring-rest/src/main/java/org/baeldung/interceptors/RestTemplateLoggingInterceptor.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp
2222
}
2323

2424
private void logRequest(byte[] body) {
25-
String payLoad = StringUtils.EMPTY;
2625
if (body.length > 0) {
27-
payLoad = new String(body, StandardCharsets.UTF_8);
26+
String payLoad = new String(body, StandardCharsets.UTF_8);
27+
System.out.println(payLoad);
2828
}
29-
System.out.println("Request Body > " + payLoad);
3029
}
3130

3231
private void logResponse(ClientHttpResponse response) throws IOException {
33-
String payLoad = StringUtils.EMPTY;
3432
long contentLength = response.getHeaders()
3533
.getContentLength();
3634
if (contentLength != 0) {
37-
payLoad = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);
35+
String payLoad = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);
36+
System.out.println(payLoad);
3837
}
39-
System.out.println("Response Body > " + payLoad);
4038
}
4139
}

0 commit comments

Comments
 (0)