Skip to content

Commit

Permalink
Closes Response.body() in Logger after rebuffering to avoid resources…
Browse files Browse the repository at this point in the history
… leak

Fixes #2529
  • Loading branch information
Nazukin-Dmitry committed Aug 29, 2024
1 parent 9b9d74f commit dc1b173
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/feign/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static feign.Util.UTF_8;
import static feign.Util.decodeOrDefault;
import static feign.Util.ensureClosed;
import static feign.Util.valuesOrEmpty;
import static java.util.Objects.nonNull;
import java.io.IOException;
Expand Down Expand Up @@ -126,6 +127,7 @@ protected Response logAndRebufferResponse(String configKey,
log(configKey, ""); // CRLF
}
byte[] bodyData = Util.toByteArray(response.body().asInputStream());
ensureClosed(response.body());
bodyLength = bodyData.length;
if (logLevel.ordinal() >= Level.FULL.ordinal() && bodyLength > 0) {
log(configKey, "%s", decodeOrDefault(bodyData, UTF_8, "Binary data"));
Expand Down

0 comments on commit dc1b173

Please sign in to comment.