-
Notifications
You must be signed in to change notification settings - Fork 143
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 string.format wrong parameter position #1921
Fix string.format wrong parameter position #1921
Conversation
Signed-off-by: Hailong Cui <[email protected]>
@ylwu-amzn Search the whole codebase also, there have few places use string.format without specifying Locale, do you think we should add for those? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1921 +/- ##
=========================================
Coverage 82.94% 82.95%
- Complexity 5414 5415 +1
=========================================
Files 521 521
Lines 21709 21709
Branches 2213 2213
=========================================
+ Hits 18007 18009 +2
+ Misses 2807 2804 -3
- Partials 895 896 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -58,7 +58,7 @@ public String getPrebuiltModelMetaListPath() { | |||
|
|||
public String getPrebuiltModelConfigPath(String modelName, String version, MLModelFormat modelFormat) { | |||
String format = modelFormat.name().toLowerCase(Locale.ROOT); | |||
return String.format("%s/%s/%s/%s/config.json", MODEL_REPO, modelName, version, format, Locale.ROOT); | |||
return String.format(Locale.ROOT, "%s/%s/%s/%s/config.json", MODEL_REPO, modelName, version, format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a simple UT that shows the behavior that is fixed? It's usually a common industry practice when fixing a bug to make sure that there is going forward a UT that clearly document the behavior change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this fix didn't change the behavior of the method. Put locale at last that will ignored by String.format method as parameters length is greater than conversions length, the superfluous one will ignored.
For UT since there already have one which will cover this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, another comment, might not be directly related to this change, but as a future FYI
this method seem like it should be static because it has no dependency on object level instance.
If we want to keep it non-static we should leverage existing parameters in the object instance instead.
@@ -58,7 +58,7 @@ public String getPrebuiltModelMetaListPath() { | |||
|
|||
public String getPrebuiltModelConfigPath(String modelName, String version, MLModelFormat modelFormat) { | |||
String format = modelFormat.name().toLowerCase(Locale.ROOT); | |||
return String.format("%s/%s/%s/%s/config.json", MODEL_REPO, modelName, version, format, Locale.ROOT); | |||
return String.format(Locale.ROOT, "%s/%s/%s/%s/config.json", MODEL_REPO, modelName, version, format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, another comment, might not be directly related to this change, but as a future FYI
this method seem like it should be static because it has no dependency on object level instance.
If we want to keep it non-static we should leverage existing parameters in the object instance instead.
Thanks, we should add this |
Signed-off-by: Hailong Cui <[email protected]> (cherry picked from commit 991193c)
Signed-off-by: Hailong Cui <[email protected]> (cherry picked from commit 991193c) Co-authored-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Description
Fix string.format wrong parameter position, the Locale should be first parameter
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.