CLDR-19409 clean up ownership of ICUServiceBuilder#5780
Conversation
addd4c0 to
31ad52d
Compare
|
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
| return longid; | ||
| } | ||
| TimezoneFormatter tzf = new TimezoneFormatter(cldrFile); | ||
| TimezoneFormatter tzf = new TimezoneFormatter(null, cldrFile); |
There was a problem hiding this comment.
CLDRFile constructor initializes a NameGetter which pulls in TimezoneFormatter which pulls in ICUServiceBuilder…… !!!!
I kind of think we should move NameGetter into ICUServiceBuilder. Then we could get rid of this.
There was a problem hiding this comment.
I think that is reasonable. We might think about whether or not it makes sense to incrementally load ICUBuilder. For example, if we are building a number formatter, maybe we just build that. If the ICU builder gets flushed in the meantime, we haven't spent time building something we don't need.
If we are building a date formatter, then that would need a number formatter. It would call a getter, which would cause the number formatter data to be loaded.
I don't know whether this would be productive or not; it would depend on how much time it takes to build an ICUServiceBuilder.
There was a problem hiding this comment.
I thought about that, splitting up functionality.
This PR makes the ownership clear. So the builder could simply initialize its own functionality only as needed.
| public static final ICUServiceBuilder inefficientSingletonServiceBuilder( | ||
| final CLDRFile resolvedFile) { | ||
| return new ICUServiceBuilder(resolvedFile, defaultCollationFactory); | ||
| } |
There was a problem hiding this comment.
| return cldrFile; | ||
| } | ||
|
|
||
| public static ICUServiceBuilder forLocale(CLDRLocale locale) { |
There was a problem hiding this comment.
note, this is a really old function.
I suspect even outside of the current issues, there may be latent bugs this was hiding.
| {"en", "one", "〖❬1 ❭Bermudan dollar〗", "〖❬1❭ ❬US dollar❭〗〖❬1❭ ❬euro❭〗"}, | ||
| { | ||
| "en", | ||
| "other", | ||
| "〖❬1.23 ❭Bermudan dollars〗〖❬0.00 ❭Bermudan dollars〗", | ||
| "〖❬1.23❭ ❬US dollars❭〗〖❬1.23❭ ❬euros❭〗〖❬0.00❭ ❬US dollars❭〗〖❬0.00❭ ❬euros❭〗" | ||
| }, |
There was a problem hiding this comment.
Test data looks suspicious here.
Now fails with:
testCurrency {
Error: (TestExampleGenerator.java:134) : en-one-BMD: expected "〖❬1 ❭Bermudan dollar〗", got "〖❬1 ❭value-one〗"
Error: (TestExampleGenerator.java:139) : en-one-pat: expected "〖❬1❭ ❬US dollar❭〗〖❬1❭ ❬euro❭〗", got "〖❬1❭_❬US dollar❭〗〖❬1❭_❬euro❭〗"
Error: (TestExampleGenerator.java:134) : en-other-BMD: expected "〖❬1.23 ❭Bermudan dollars〗〖❬0.00 ❭Bermudan dollars〗", got "〖❬1.23 ❭value-other〗〖❬0.00 ❭value-other〗"
Error: (TestExampleGenerator.java:139) : en-other-pat: expected "〖❬1.23❭ ❬US dollars❭〗〖❬1.23❭ ❬euros❭〗〖❬0.00❭ ❬US dollars❭〗〖❬0.00❭ ❬euros❭〗", got "〖❬1.23❭_❬US dollars❭〗〖❬1.23❭_❬euros❭〗〖❬0.00❭_❬US dollars❭〗〖❬0.00❭_❬euros❭〗"
} (0.001s) FAILED (4 failure(s))
But the value we're using is "value-one". If anything it looks like it was using the wrong results.
There was a problem hiding this comment.
I don't understand. the following looks reasonable to me. other means plural, all all the examples are plural.
"en",
"other",
"〖❬1.23 ❭Bermudan dollars〗〖❬0.00 ❭Bermudan dollars〗",
"〖❬1.23❭ ❬US dollars❭〗〖❬1.23❭ ❬euros❭〗〖❬0.00❭ ❬US dollars❭〗〖❬0.00❭ ❬euros❭〗"
There was a problem hiding this comment.
But this is the scenario the test sets up: the English value has been changed to value-one and value-other respectively. Just as with French.
I simulated the situation with en_CA locally:
Why does the test expect Bermudan dollars to be the value? I think it was passing because of ownership errors in the ExampleGenerator. Compare to the French test in this same unit test, where the values are value-one and value-other.
| (locIsExceptional || fileIsRecording) | ||
| ? new ICUServiceBuilder(resolvedCldrFile, locIsExceptional) | ||
| : ICUServiceBuilder.forLocale(CLDRLocale.getInstance(localeId)); | ||
| this.icuServiceBuilder = cldrFactory.getICUServiceBuilder(CLDRLocale.getInstance(localeId)); |
There was a problem hiding this comment.
This fails TestCLDRPaths.testGenerateExampleDependencies I recently added in #5761 . The value of boolean fileIsRecording can't be ignored; see the comment a few lines above. If an ExampleGenerator has a RecordingCLDRFile, then its ICUServiceBuilder needs to use that same RecordingCLDRFile.
The boolean locIsExceptional is also getting ignored with this change. It's not clear to me whether that's OK; maybe it is if the proposed cldrFactory.getICUServiceBuilder handles exceptional locales correctly, unlike ICUServiceBuilder.forLocale. If locIsExceptional isn't needed anymore it should be removed.
There was a problem hiding this comment.
I'm looking at that now. Yes exceptional should be removed, no more exceptional locales.
There was a problem hiding this comment.
@btangmu take a look at the last update. This preserves the recording CLDRFile.
Even cleaner would be to have a recording Factory, that would work correctly (and would even cache the service builder by returning the same recording file…). Perhaps a future update.
There was a problem hiding this comment.
I'm not sure what you mean by "the last update". I see 4 commits; is there a 5th commit pending that I don't see yet?
There was a problem hiding this comment.
ah yes, commited but not pushed. pushed it now.
use singleton ICUSertviceBuilder when using a recording file

CLDR-19409
Completely get rid of
ICUServiceBuilder.forLocale()Instead,
ICUServiceFactorycontains the cache, and, everyFactoryownes one.Perf should be the same or better.
Also fixes CLDR-19518 and CLDR-19166
ALLOW_MANY_COMMITS=true