[Java][okhttp-gson] Use builder api of OkHttpClient to avoid UnsupportedOperationEx#5177
Merged
wing328 merged 5 commits intoOpenAPITools:masterfrom Feb 13, 2020
Merged
Conversation
added 5 commits
January 31, 2020 10:21
The reason for the UnsupportedOperationException was an invalid access to the interceptors list of OkHttpClient. That list is unmodifiable as stated by the JavaDoc. Instead accessing the list directly, the interceptors should always be passed when building the client by the builder api.
The reason for the UnsupportedOperationException was an invalid access to the interceptors list of OkHttpClient. That list is unmodifiable as stated by the JavaDoc. Instead accessing the list directly, the interceptors should always be passed when building the client by the builder api.
Member
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
wing328
reviewed
Feb 13, 2020
| // Enable gzip request compression | ||
| httpClient.interceptors().add(new GzipRequestInterceptor()); | ||
| // Enable gzip request compression | ||
| builder.addInterceptor(new GzipRequestInterceptor()); |
Member
There was a problem hiding this comment.
@trohrberg seems like these 2 lines are not indented correctly. I'll file a separate PR to update it after merging this one.
Member
|
Let's go with your proposed fix. Thanks for the PR. |
MikailBag
pushed a commit
to MikailBag/openapi-generator
that referenced
this pull request
Mar 23, 2020
…tedOperationEx (OpenAPITools#5177) * 3432 Use builder api of OkHttpClient to avoid UnsupportedOperationEx The reason for the UnsupportedOperationException was an invalid access to the interceptors list of OkHttpClient. That list is unmodifiable as stated by the JavaDoc. Instead accessing the list directly, the interceptors should always be passed when building the client by the builder api. * 3432 Use builder api of OkHttpClient to avoid UnsupportedOperationEx The reason for the UnsupportedOperationException was an invalid access to the interceptors list of OkHttpClient. That list is unmodifiable as stated by the JavaDoc. Instead accessing the list directly, the interceptors should always be passed when building the client by the builder api. * 3432 Follow-up fix to make samples compile again * 3432 Updated sample implementation for okHttp-Gson-ParcelableModel
Member
|
@trohrberg thanks for the PR, which has been included in the 4.3.0 release: https://twitter.com/oas_generator/status/1243455743937789952 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Issue #3432
Changed the template for generating the ApiClient.java class for Java with okhttp-gson library so that the GzipRequestInterceptor and the RetryingOauth interceptors are added to the OkHttpClient builder before building it. This avoids modifying the immutable list of interceptors which caused the UnsupportedOperationException before.
@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @bkabrda (2020/01)
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.