Skip to content

Commit 8a7b688

Browse files
committed
Convert byte array to string for logging in ProxyResponse
1 parent 531929a commit 8a7b688

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyResponseHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
import io.trino.gateway.proxyserver.ProxyResponseHandler.ProxyResponse;
2222

2323
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.nio.charset.Charset;
26+
import java.nio.charset.StandardCharsets;
2427

25-
import static com.google.common.io.ByteStreams.toByteArray;
2628
import static java.util.Objects.requireNonNull;
29+
import static org.openjdk.jol.util.IOUtils.readAllBytes;
2730

2831
public class ProxyResponseHandler
2932
implements ResponseHandler<ProxyResponse, RuntimeException>
@@ -38,7 +41,7 @@ public ProxyResponse handleException(Request request, Exception exception)
3841
public ProxyResponse handle(Request request, Response response)
3942
{
4043
try {
41-
return new ProxyResponse(response.getStatusCode(), response.getHeaders(), toByteArray(response.getInputStream()));
44+
return new ProxyResponse(response.getStatusCode(), response.getHeaders(), new String(response.getInputStream().readAllBytes(), Charset.defaultCharset()));
4245
}
4346
catch (IOException e) {
4447
throw new ProxyException("Failed reading response from remote Trino server", e);
@@ -48,7 +51,7 @@ public ProxyResponse handle(Request request, Response response)
4851
public record ProxyResponse(
4952
int statusCode,
5053
ListMultimap<HeaderName, String> headers,
51-
byte[] body)
54+
String body)
5255
{
5356
public ProxyResponse
5457
{

0 commit comments

Comments
 (0)