On Thu, 26 Dec 2024 16:39:58 GMT, Brett Okken <d...@openjdk.org> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Fixed compile error > > src/java.base/share/classes/java/time/format/DateTimeTextProvider.java line > 316: > >> 314: store = createStore(field, locale); >> 315: CACHE.putIfAbsent(key, store); >> 316: store = CACHE.get(key); > > should this be > `store = CACHE.computeIfAbsent(key, e -> createStore(e.getKey(), > e.getValue()));` > > That still allow the optimistic/concurrent get call to succeed most of the > time (when already cached) but reduce the interactions with the map when a > value is created/set/accessed the first time. > > Alternatively, the result of `putIfAbsent` could be checked/used to avoid the > second call to `get`. For sure we should use result of `putIfAbsent`. Let's do this for all cases. See how it was implemented in my first commit - https://github.com/openjdk/jdk/pull/9208/commits/73a2f6cb1b91f4d7ee374089f35a72ef7b94433b ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22854#discussion_r1898031238