On Wed, 28 Jun 2023 11:05:11 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:
> Double-checked locking should rely on local variable to avoid racy reads from > volatile field. True. I was mislead because the return statement does not appear in the changeset (the line is textually the same, although it has a different semantics: `keySet` now refers to a local), so I didn't count for it. In the end, this PR is not about fixing a race, as the title seems to suggest (the original code is correct), but to avoid a volatile read, right? ------------- PR Comment: https://git.openjdk.org/jdk/pull/14692#issuecomment-1614317093