RFR: 8280041: Retry loop issues in java.io.ClassCache [v4]

Aleksey Shipilev shade at openjdk.java.net
Tue Jan 25 16:15:30 UTC 2022


On Mon, 24 Jan 2022 21:32:16 GMT, Peter Levart <plevart at openjdk.org> wrote:

> This looks good, although I don't know whether the additional check for strongReferent != null is needed in clearStrong(). This is all racy code and you have already got a non-null return from getStrong() in case you are calling clearStrong()...

This seems like a standard thing to do to avoid multi-threaded write contention under the race. By the time one thread calls `clearStrong`, some other thread might have already cleared it, and we don't have to clear again. Granted, that is a micro-optimization, but I'd like to avoid surprises on this path :)

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

PR: https://git.openjdk.java.net/jdk/pull/7092


More information about the core-libs-dev mailing list