RFR: 8229899: java.io.File.isInvalid() is racy

Alan Bateman Alan.Bateman at oracle.com
Tue Aug 20 09:39:34 UTC 2019


On 20/08/2019 00:14, Arthur Eubanks wrote:
> Bug: https://bugs.openjdk.java.net/browse/JDK-8229899
> Webrev: http://cr.openjdk.java.net/~aeubanks/8229899/webrev.00/
>
>      final boolean isInvalid() {
>          if (status == null) {
>              status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
>                                                         :
> PathStatus.INVALID;
>          }
>          return status == PathStatus.INVALID;
>      }
> If the reads to "status" are reordered and another thread writes to
> "status", the return value can be wrong.
> Reading "status" to a local variable fixes the issue.
An oversight in JDK-8003992 that we missed during the review at the 
time. The change looks good.

-Alan.


More information about the core-libs-dev mailing list