On Wed, 1 Jun 2022 04:10:03 GMT, ExE Boss <d...@openjdk.java.net> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Removed unnecessary clone() call > > src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java line > 181: > >> 179: .toArray(Locale[]::new); >> 180: } >> 181: return AVAILABLE_LOCALES; > > This should probably clone the cached array: > Suggestion: > > return AVAILABLE_LOCALES.clone(); > > > Matching what `JRELocaleProviderAdapter` does[^1], since there’s no guarantee > that the result of `getAvailableLocales()` won’t be mutated. > > [^1]: > https://github.com/openjdk/jdk/blob/6b1169e266b9d21864f886ef574dd64116fa2cb0/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java#L430-L439 Thanks for your comments. In fact, `clone()` in `JRELocaleProviderAdapter` is not necessary, as it will be subsumed into `Locale.getAvailableLocales()` and other `getAvailableLocales()` methods in locale sensitives services (such as `DateFormat`) where they are defensively cloned. Removed this `clone()` invocation. ------------- PR: https://git.openjdk.java.net/jdk/pull/8960