[ggj]fix: handle special characters in string object value#72
[ggj]fix: handle special characters in string object value#72xiaozhenliu-gg5 merged 55 commits intomasterfrom
Conversation
…ator-java into fix-string-object
…ator-java into fix-string-object
…ator-java into fix-string-object
…ator-java into fix-string-object
|
|
| public StringObjectValue build() { | ||
| // `\"` is added to the escaped string value for interpreting it correctly in file. | ||
| String value = | ||
| String.format("\"%s\"", StringValueEscaper.getInstance().escape(autoBuild().value())); |
There was a problem hiding this comment.
Instead of calling autoBuild twice, what about just using value()? IIRC we discussed this in a prior review.
There was a problem hiding this comment.
right, we had this discussion, here we cannot use value() because it's not static, Builder class has static context.
There was a problem hiding this comment.
One way to avoid calling autoBuild() twice is to add a "private" value() method to the Builder class. Please see the other examples in this codebase.
There was a problem hiding this comment.
Right! Thank you for the advice, also found this doc that illustrate how/why it works. Learned from this PR!
| return escaper.escape(sourceString); | ||
| } | ||
|
|
||
| public static Escaper getInstance() { |
There was a problem hiding this comment.
Consider whether this method is still needed.
There was a problem hiding this comment.
yes! This is basically for wrapping the escape() in as a static method so that we can call it from the static context (class Builder).
There was a problem hiding this comment.
Could you please try calling escape() without getInstance() and consider whether getInstance() is still needed?
There was a problem hiding this comment.
sorry if I confused you, but I did try remove the getInstance()and directly call StringValueEscaper.escape(value) and it throws error of cannot calling a non-static method from static context. since the override escape() is not static.
String value = String.format("\"%s\"", StringValueEscaper.escape(value()));
please LMK if I did something wrong.
There was a problem hiding this comment.
But this works, thank you!
String value = String.format("\"%s\"", StringValueEscaper.escaper.escape(value()));
There was a problem hiding this comment.
TWIL: if the member or constructor is declared private, then access is permitted if and only if it occurs within the body of the top level class that encloses the declaration of the member or constructor.
| public StringObjectValue build() { | ||
| // `\"` is added to the escaped string value for interpreting it correctly in file. | ||
| String value = | ||
| String.format("\"%s\"", StringValueEscaper.getInstance().escape(autoBuild().value())); |
There was a problem hiding this comment.
One way to avoid calling autoBuild() twice is to add a "private" value() method to the Builder class. Please see the other examples in this codebase.
…ator-java into fix-string-object
…onfig to v0.8.0 (#72) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [com.google.cloud:google-cloud-shared-config](https://togithub.com/googleapis/java-shared-config) | minor | `0.6.0` -> `0.8.0` | --- ### Release Notes <details> <summary>googleapis/java-shared-config</summary> ### [`v0.8.0`](https://togithub.com/googleapis/java-shared-config/blob/master/CHANGELOG.md#​080-httpswwwgithubcomgoogleapisjava-shared-configcomparev070v080-2020-06-10) [Compare Source](https://togithub.com/googleapis/java-shared-config/compare/v0.7.0...v0.8.0) ##### Features - revert "feat: mark auto-value-annotations scope as provided" ([#​154](https://www.github.com/googleapis/java-shared-config/issues/154)) ([88afb4e](https://www.github.com/googleapis/java-shared-config/commit/88afb4e7c57cb6e00929c098135314a926d9da30)) ### [`v0.7.0`](https://togithub.com/googleapis/java-shared-config/blob/master/CHANGELOG.md#​070-httpswwwgithubcomgoogleapisjava-shared-configcomparev060v070-2020-06-10) [Compare Source](https://togithub.com/googleapis/java-shared-config/compare/v0.6.0...v0.7.0) ##### Features - mark auto-value-annotations scope as provided ([#​151](https://www.github.com/googleapis/java-shared-config/issues/151)) ([44ea4cb](https://www.github.com/googleapis/java-shared-config/commit/44ea4cbbf92b4ad35ffaffb7a01a1bce05063daf)) ##### Bug Fixes - lock the google-java-format version used by formatter plugin ([#​149](https://www.github.com/googleapis/java-shared-config/issues/149)) ([d58c054](https://www.github.com/googleapis/java-shared-config/commit/d58c05437a4ea8767db2bebfcc405ec77aeb9705)) </details> --- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/java-shared-dependencies).
resolve left comments in #61
more details can be found in the design doc, investigation is appended.