# HG changeset patch # User aeubanks # Date 1566256108 25200 # Node ID a445d4305fad756fa62300959df0fa4c17b8dd4c # Parent 348f7933e2ccda7ee6ce33e4f547652eee8db9ef 8229899: Make java.io.File.isInvalid() less racy Reviewed-by: alanb, martin, shade diff -r 348f7933e2cc -r a445d4305fad src/java.base/share/classes/java/io/File.java --- a/src/java.base/share/classes/java/io/File.java Tue Aug 20 15:40:49 2019 +0100 +++ b/src/java.base/share/classes/java/io/File.java Mon Aug 19 16:08:28 2019 -0700 @@ -182,11 +182,13 @@ * @return true if the file path is invalid. */ final boolean isInvalid() { - if (status == null) { - status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED - : PathStatus.INVALID; + PathStatus s = status; + if (s == null) { + s = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED + : PathStatus.INVALID; + status = s; } - return status == PathStatus.INVALID; + return s == PathStatus.INVALID; } /**