<i18n dev> RFR: 8347955: TimeZone methods to stream the available timezone IDs [v3]
Chen Liang
liach at openjdk.org
Thu Jan 23 22:50:47 UTC 2025
On Thu, 23 Jan 2025 22:23:29 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/TimeZone.java line 659:
>>
>>> 657: * @since 25
>>> 658: */
>>> 659: public static synchronized Stream<String> availableIDs(int rawOffset) {
>>
>> Why are these new methods synchronized? I think the streams and the spliterators are late-binding, so the synchronization does not synchronize the access to the underlying arrays. synchronized modifier also does not appear in Javadoc and is not part of the API surface, so it can be safely removed.
>
> Right, it can be removed. Actually, I think `getAvailableIDs()` and `getAvailableIDs(int)` also do not need to be synchronized. The internal IDs are eagerly initialized in the static block of `ZoneInfoFile.java` and are effectively final and not modified.
Yep; their synchronized are incorrect. The object monitor lock should have been on `ZoneInfoFile.class` to be effective.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23251#discussion_r1927788351
More information about the i18n-dev
mailing list