<i18n dev> RFR: 8309622: Re-examine the cache mechanism in BaseLocale [v2]

Naoto Sato naoto at openjdk.org
Mon Jun 12 17:33:11 UTC 2023


On Mon, 12 Jun 2023 14:35:15 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> One thing though - WeakHashMap is not thread safe - and I don't see any locks or synchronized to protect access to CACHE. Is that going to cause trouble if two threads compete to add a locale to the map? In other words - how confident are we that the race would be benign?

Although I think the possible race is benign (it would simply overwrite the existing normalized one), I put it in a synchronization block as a safety measure, as the race would be quite rare for creating a BaseLocale instance. Tested with the microbench mark and I didn't see the number change.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14404#issuecomment-1587759179


More information about the i18n-dev mailing list