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

fix: Use UTF-8 as default charset for HttpJson requests #1477

Merged
merged 12 commits into from
Mar 20, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented Mar 10, 2023

Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1437

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 10, 2023
@lqiu96 lqiu96 marked this pull request as ready for review March 13, 2023 17:24
@lqiu96 lqiu96 requested a review from a team as a code owner March 13, 2023 17:24
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 13, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 13, 2023
@lqiu96 lqiu96 requested a review from blakeli0 March 13, 2023 17:28
@blakeli0
Copy link
Collaborator

Thanks Lawrence! This is a perfect example that showcase can help us identify bugs in our implementation, cc @burkedavison @mpeddada1

@@ -172,7 +172,7 @@ HttpRequest createHttpRequest() throws IOException {
jsonFactory.createJsonParser(requestBody).parse(tokenRequest);
jsonHttpContent =
new JsonHttpContent(jsonFactory, tokenRequest)
.setMediaType((new HttpMediaType("application/json")));
.setMediaType((new HttpMediaType("application/json; charset=utf-8")));
Copy link
Collaborator

@blakeli0 blakeli0 Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good to me! This makes me think though, we are currently hardcoding all content type to application/json, which is fine for now, but it will not work for services like storage in the future. It might be one of the reasons that storage has been a handwritten library. CC @meltsufin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my curiosity: What content-type does Storage use? Wondering if it's as easy as setting the charset or having to create/ modify the HttpMediaType class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the use case, in their example, it is set to text/plain. We probably need to make it a parameter in the future and set it differently based on the scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll create an issue to track this. Might be something that a future GAPIC library needs. Also, don't the handwritten libraries use java-core instead of gax?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They use both, also we are thinking about reducing the need of handwritten libraries(including java-core), so this could be one of places. I wouldn't create an issue yet as we don't have the need yet, but something to keep in mind.

release-please bot and others added 4 commits March 20, 2023 13:32
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…ase and gax modules (#1430)

* chore: add aggregate test coverage collection for showcase and gax
* feat: install clirr check

* install an independent action

* format changes

* change name

* change action name
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Mar 20, 2023
@sonarcloud
Copy link

sonarcloud bot commented Mar 20, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@lqiu96 lqiu96 added the automerge Merge the pull request once unit tests and other checks pass. label Mar 20, 2023
@gcf-merge-on-green gcf-merge-on-green bot merged commit 79d986b into main Mar 20, 2023
@gcf-merge-on-green gcf-merge-on-green bot deleted the main-httpjson_default_charset branch March 20, 2023 17:52
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Mar 20, 2023
lqiu96 added a commit to renovate-bot/gapic-generator-java that referenced this pull request Mar 20, 2023
)

Thank you for opening a Pull Request! For general contributing guidelines, please refer to [contributing guide](https://togithub.com/googleapis/gapic-generator-java/blob/main/CONTRIBUTING.md)

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

- [x] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/gapic-generator-java/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)

Fixes googleapis#1437
lqiu96 added a commit to renovate-bot/gapic-generator-java that referenced this pull request Mar 21, 2023
)

Thank you for opening a Pull Request! For general contributing guidelines, please refer to [contributing guide](https://togithub.com/googleapis/gapic-generator-java/blob/main/CONTRIBUTING.md)

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

- [x] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/gapic-generator-java/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)

Fixes googleapis#1437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set the default charset as UTF-8 for REST calls with application/json MediaType
5 participants