这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: update usages of String.format to explicitly pass Locale.US #2974

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

BenWhitehead
Copy link
Collaborator

Usage of Storage#format(String, Object...) will use the default locale for it's formatting. This can lead to unexpected formatting if a right-to-left language such as Arabic is the default locale.

Update all usages to use String.format(Locale.US, pattern, Object...) so we ensure things like headers or error messages are formatted according to the US conventions which match en_US and ascii byte conventions.

Incidentally, things like right-to-left formatting seem to only apply to java11+ not java8.

Fixes #2972

Usage of `Storage#format(String, Object...)` will use the default locale for it's formatting. This can lead to unexpected formatting if a right-to-left language such as Arabic is the default locale.

Update all usages to use `String.format(Locale.US, pattern, Object...)` so we ensure things like headers or error messages are formatted according to the US conventions which match `en_US` and ascii byte conventions.

Incidentally, things like right-to-left formatting seem to only apply to java11+ not java8.

Fixes #2972
@BenWhitehead BenWhitehead requested a review from a team as a code owner March 5, 2025 19:58
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/java-storage API. labels Mar 5, 2025
Copy link
Contributor

@ddelgrosso1 ddelgrosso1 left a comment

Choose a reason for hiding this comment

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

Yowza! This touches a lot of files but looks pretty boilerplate

@BenWhitehead BenWhitehead merged commit 8bcb2de into main Mar 5, 2025
21 checks passed
@BenWhitehead BenWhitehead deleted the format-explicit-locale branch March 5, 2025 22:08
@nicktindall
Copy link

Incidentally, things like right-to-left formatting seem to only apply to java11+ not java8.

Perhaps related to https://openjdk.org/jeps/252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storage: Content-Range header is formatted with default locale
3 participants