On Mon, 30 Jan 2023 07:11:57 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:

>> This PR proposes introducing a new method to Locale which returns 
>> Stream<Locale>
>> 
>> It involves adding an additional method to _LocaleServiceProviderPool_ that 
>> returns Stream, which _Locale_ can call.
>> 
>> `LocaleServiceProviderPool.streamAllAvaliableLocales()` does not need a 
>> defensive copy of `AllAvailableLocales.allAvailableLocales` unlike 
>> `LocaleServiceProviderPool.getAllAvaliableLocales()` as the array is hidden 
>> by the Stream.
>
> src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java
>  line 160:
> 
>> 158:      */
>> 159:     public static Stream<Locale> streamAvailableLocales() {
>> 160:         return AllAvailableLocales.AvailableLocalesSet.stream();
> 
> I think we could use `Stream.of(AllAvailableLocales.availableLocalesArray)` 
> here and drop set field.

Yes you're right, I had misinterpreted the original bug description. Set is not 
required, and in fact the array should be streamed directly as you said.

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

PR: https://git.openjdk.org/jdk/pull/12269

Reply via email to