On Jul 3, 2014, at 6:33 PM, Alan Bateman <alan.bate...@oracle.com> wrote: > On 03/07/2014 09:43, Peter Levart wrote: >> Hi, >> >> I noticed a data race in java.net.URL: >> >> https://bugs.openjdk.java.net/browse/JDK-8049220 >> >> I propose the following simple patch: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/URL.factory/webrev.01/ >> > A good catch and the change looks good to me.
Yes, well spotted. May i suggest that the following comment is updated: 1109 factory = fac; // volatile write to say something about ensuring safe publication of a constructed handle? since it is often quite tricky to reason about why a volatile write is needed (to stamp in, at least, a StoreStore barrier). For JMM v9 we may not need to mark such a ref as volatile. > I assume it just wasn't noticed because it can only be set once and probably > rared used too. > Yeah, i wonder whether it would ever get optimized/inlined to the point at which re-ordering could practically happen. Paul.
signature.asc
Description: Message signed with OpenPGP using GPGMail