Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve materializing input stream in the client #25171

Merged
merged 8 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public static <T> JsonResponse<T> execute(TrinoJsonCodec<T> codec, Call.Factory
if (isJson(responseBody.contentType())) {
T value = null;
IllegalArgumentException exception = null;
MaterializingInputStream stream = new MaterializingInputStream(responseBody.byteStream(), 128 * 1024);
MaterializingInputStream stream = new MaterializingInputStream(responseBody.byteStream(), 8 * 1024);
try (InputStream ignored = stream) {
// Parse from input stream, response is either of unknown size or too large to materialize. Raw response body
// will not be available if parsing fails
// Parse from input stream, response is either of unknown size or too large to materialize.
// 8K of the response body will be available if parsing fails.
value = codec.fromJson(stream);
}
catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MaterializingInputStream
protected MaterializingInputStream(InputStream stream, int maxBytes)
{
super(stream);
verify(maxBytes > 0 && maxBytes <= 128 * 1024, "maxBytes must be between 1 and 128 KB");
verify(maxBytes > 0 && maxBytes <= 8 * 1024, "maxBytes must be between 1B and 8 KB");
this.head = new byte[maxBytes];
}

Expand Down