> On Mar 12, 2018, at 11:42 AM, Claes Redestad <claes.redes...@oracle.com> > wrote: > > Hi, > > mixing volatiles and non-volatiles fields that are read and written to > outside of > synchronized makes me somewhat queasy… >
Synchronizing on a string also makes me queasy, especially given that string can be input by the user, i dunno if there is any interning going on… It's a little dirty but you might be able to piggyback off another field e.g. those of ExpiringCache. Paul. > Instead of a volatile boolean and a mutable userDir field, couldn't this just > as well be modelled as: > > - keep userDir final (always the not normalized value of > System.getProperty("user.dir")) > - replace volatile boolean isUserDirNormal with volatile String > normalizedUserDir > - then implement the DCL in getUserPath like: > > String normalizedUserDir = this.normalizedUserDir; > if (normalizedUserDir == null) { > synchronized(userDir) { > if (normalizedUserDir == null) { > normalizedUserDir = this.normalizedUserDir = normalize(userDir); > } > } > } > return normalizedUserDir; > > WDYT? > > /Claes > > On 2018-03-12 19:32, Brian Burkhalter wrote: >> https://bugs.openjdk.java.net/browse/JDK-8198997 >> http://cr.openjdk.java.net/~bpb/8198997/webrev.00/ >> >> Lazily cache the value of the user.dir property on first access. This change >> is for Windows only as there does not appear to be any percentage in doing >> something similar on Unix. >> >> Thanks, >> >> Brian >