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

ICU-20558 Fix resource fallback logic in ures_getFunctionalEquivalent #621

Conversation

gvictor
Copy link
Collaborator

@gvictor gvictor commented Apr 12, 2019

@gvictor gvictor requested a review from markusicu April 12, 2019 18:00
@markusicu markusicu requested a review from yumaoka April 12, 2019 18:41
@@ -2632,7 +2632,8 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity,
#endif
if(U_FAILURE(subStatus)) {
*status = subStatus;
} else if(subStatus == U_ZERO_ERROR) {
} else if(subStatus == U_ZERO_ERROR || subStatus == U_USING_DEFAULT_WARNING) {
Copy link
Member

Choose a reason for hiding this comment

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

For reference: This looks similar to ICU-20431 (PR #377) and the fix in commit 290feb3 which I first proposed for it in January, but which then was rejected in the TC meeting and replaced with the fix in commit 092afb3 instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I still reproduced the issue in the latest master. How does commit #092afb3 fix this issue?

Copy link
Collaborator Author

@gvictor gvictor Apr 15, 2019

Choose a reason for hiding this comment

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

Particularly, it's a regression in ICU 63 or lower. Do you know which commmit caused the regression?

Copy link
Member

Choose a reason for hiding this comment

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

How does commit #092afb3 fix this issue?

It does not, it fixes a different (but somewhat related) issue.

Do you know which commmit caused the regression?

Sorry, no.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, since your change was not accepted, I guess I suspect that an invalid locale "abc" should not fallback to the default locale.

But I think it should at least fallback to the root locale. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

b12a927
this commit caused the regression.
Specifically, the new error check in DateTimePatternGenerator::getCalendarTypeToUse

Copy link
Member

@jefgen jefgen Apr 15, 2019

Choose a reason for hiding this comment

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

Thanks for tracking down the change @gvictor.

Here is a link to the line in the PR diff:
b12a927#diff-14f1d714f00a6f21e52eae73ad7fa1e4R771

The change added a check for failure after calling ures_getFunctionalEquivalent, as before there was no check at all.
If ures_getFunctionalEquivalent failed (imagine an out-of-memory failure) then the code would continue and would eventually return U_ZERO_ERROR.

I don't think hiding catastrophic errors like OOM is good practice, so I'm somewhat inclined to keep the check in place. Perhaps it could be weakened to allow U_MISSING_RESOURCE_ERROR though?

@@ -2632,7 +2632,8 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity,
#endif
if(U_FAILURE(subStatus)) {
*status = subStatus;
} else if(subStatus == U_ZERO_ERROR) {
} else if(subStatus == U_ZERO_ERROR || subStatus == U_USING_DEFAULT_WARNING) {
subStatus = U_ZERO_ERROR;
ures_getByKey(res,resName,&bund1, &subStatus);
if(subStatus == U_ZERO_ERROR) {
Copy link
Member

Choose a reason for hiding this comment

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

^ subStatus was just compared 2 lines before

@jefgen
Copy link
Member

jefgen commented Apr 23, 2019

Thanks @gvictor.
FWIW, for the specific issue in ICU-20558, I the PR here might be more narrowly scoped: #632
This PR would effect other usages of ures_getFunctionalEquivalent beyond the DateTimePatternGenerator issue.

@gvictor
Copy link
Collaborator Author

gvictor commented Apr 23, 2019

Thanks @jefgen . I am closing this PR in favour of your change.

@gvictor gvictor closed this Apr 23, 2019
@gvictor gvictor deleted the DateTimePatternGenerator_invalid_locale branch April 23, 2019 18:03
@unicode-org unicode-org deleted a comment Sep 11, 2019
@unicode-org unicode-org deleted a comment Sep 11, 2019
@unicode-org unicode-org deleted a comment Sep 11, 2019
@unicode-org unicode-org deleted a comment Sep 11, 2019
@unicode-org unicode-org deleted a comment Sep 11, 2019
@unicode-org unicode-org deleted a comment Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants