Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8229899

java.io.File.isInvalid() is racy

XMLWordPrintable

    • b11

            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.

              aeubanks Arthur Eubanks
              aeubanks Arthur Eubanks
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: