-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[Java][okhttp-gson] support deserializing from InputStream instead of String to bypass 2GB Java String limit #21115
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
[Java][okhttp-gson] support deserializing from InputStream instead of String to bypass 2GB Java String limit #21115
Conversation
…ing to bypass 2GB Java String limit
|
https://github.com/OpenAPITools/openapi-generator/actions/runs/14587151272/job/40918080042?pr=21115 please update |
@wing328 ah I missed that, thank you! I have updated the |
| `authorization` header. | ||
| - `scopes`: a list of Strings represenging OAuth2 scopes. | ||
| - `options`: a keyword list of OpenAPIPetstore.Connection.options. | ||
| - `options`: a keyword list of {{moduleName}}.Connection.options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a rebase failed and some other changes not authored by you are also included.
given that only a few elixir related changes (already merged into master) are included, we will accept these this time.
|
This change misses the fallback logic: Lines 193 to 201 in 2c7efda
Kubernetes client-java breaks in certain use cases because of this. |
|
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)__
Overview
Fixes issue kubernetes-client/java#4020 .
Makes two changes:
okhttp-gsonApiClient, if we are deserializing JSON, get the response body as anInputStreaminstead ofStringfor deserialization.JSON, add a new deserialize() method in which acceptsInputStream.These two changes enable the
ApiClientto bypass the 2GBStringlength limit in Java and deserialize large responses greater than 2GB into Java objects.Root Cause
When the response is too large, we get an error like this:
This issue occurs because the response body is converted to a String here in the ApiClient, which hits this validation in
okhttp:require(byteCount >= 0 && byteCount <= Integer.MAX_VALUE) { "byteCount: $byteCount" }because of Java's String max length limit of Integer.MAX_VALUE which is 2^31 - 1.