RFR: 8302849: SurfaceManager might expose partially constructed object
Per Minborg
pminborg at openjdk.org
Mon Feb 20 10:33:01 UTC 2023
This PR proposes to add `volatile` to a variable declaration in order to prevent partially initialized objects to be observed by threads.
`SurfaceManager` is using a lazily initialized cacheMap that is initialized using a double-checked locking mechanism. Generally, objects initialized using such constructs need to be declared volatile.
See https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
-------------
Commit messages:
- Prevent partially constructed object to be observed
Changes: https://git.openjdk.org/jdk/pull/12654/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12654&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8302849
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/12654.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12654/head:pull/12654
PR: https://git.openjdk.org/jdk/pull/12654
More information about the client-libs-dev
mailing list