Skip to content

Commit de0127c

Browse files
author
ennoeller
committed
Retrofit response body mapper fix
1 parent 18cc9c2 commit de0127c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
}
2020

2121
group 'ee.bitweb'
22-
version '4.0.1'
22+
version '4.0.2'
2323
java {
2424
sourceCompatibility = '17'
2525
}

src/main/java/ee/bitweb/core/retrofit/logging/mappers/RetrofitResponseBodyMapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ private String parseBody(Response response) throws IOException {
8686

8787
if (contentLength != 0L) {
8888
var bodyString = buffer.clone().readString(charset);
89-
if (contentLength > maxLoggableResponseSize) {
89+
var bodyStringLength = bodyString.length();
90+
91+
if (bodyStringLength > maxLoggableResponseSize) {
9092
return "%s ... Content size: %s characters".formatted(
9193
bodyString.substring(0, maxLoggableResponseSize),
92-
contentLength
94+
bodyStringLength
9395
);
96+
} else {
97+
return sanitizeBody(bodyString);
9498
}
95-
96-
return sanitizeBody(bodyString);
9799
} else {
98100
return "";
99101
}

0 commit comments

Comments
 (0)