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

reuse Configuration.defaultApiClientin no-arg Api ctors and make ref volatile (fixes issue #20633) #20635

Merged
merged 11 commits into from
Feb 19, 2025

Conversation

ronreynolds
Copy link
Contributor

@ronreynolds ronreynolds commented Feb 10, 2025

fixes issue #20633

this PR changes the following (all within java:native):

  • fixes a broken (or at least time-zone-sensitive) unit-test from fix: CodeGen correctly produces yyyy-mm-dd format for date with examples #20516
    • also tweaks unit-test slightly so it prints value that failed expectations rather than just failing with a line number
  • makes Configuration.defaultApiClient volatile so that changes will be synced across threads
  • reuses Configuration.defaultApiClient in no-arg ctors of *Api classes to avoid needless creation of new ApiClients
  • replaces equivalent calls to URLEncoder.encode(..., StandardCharsets.UTF_8).replaceAll("\\+", "%20") with calls to ApiClient.urlEncode(...)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project
    ./mvnw clean package || exit
    
  • and update samples:
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

(is it not possible to create an alias for the java technical committee?)
@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) @martin-mfg (2023/08)

@martin-mfg
Copy link
Contributor

Hi @ronreynolds, thanks for the PR! The changes look good to me.
The pipeline failure seems to be unrelated to the changes in this PR. To fix the pipeline and make this PR mergeable, could you please merge the latest master into your branch? And you probably also need to update the samples, as described in the "PR checklist" in your post above.

@ronreynolds
Copy link
Contributor Author

@martin-mfg done. sync'ed with master, generated new samples (a little shocked there were so many but i guess that's what happens when you mess with anyof, oneof, and pojo mustache files).

@wing328
Copy link
Member

wing328 commented Feb 18, 2025

thanks for the PR. can you please review the test failure when you've time?

@ronreynolds
Copy link
Contributor Author

ronreynolds commented Feb 18, 2025

@wing328 it failed due to

Run /bin/sh gradlew build -x test
Downloading https://services.gradle.org/distributions/gradle-8.7-bin.zip
............10%.............20%.............30%..
Error: The operation was canceled.

bandwidth issue? (since it appears the download started but didn't finish). 🤔

EDIT:
my bad; there was yet another issue. looking into that now.

EDIT:
looks like a missing import; not sure why it didn't show up in the local build. will push fix asap.

@ronreynolds
Copy link
Contributor Author

pushed fix for missing import of ApiClient in 2 other model mustache files; verified build of petstore/native and petstore/native-async locally; this should address all the issues of which i am aware with this PR. 🤞

@wing328 wing328 merged commit eb668b6 into OpenAPITools:master Feb 19, 2025
101 checks passed
@wing328
Copy link
Member

wing328 commented Feb 19, 2025

thanks for the PR, which has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants