8229899: Make java.io.File.isInvalid() less racy

Reviewed-by: alanb, martin, shade
This commit is contained in:
Arthur Eubanks 2019-08-19 16:08:28 -07:00
parent c99c1f8d55
commit 916c2e3cf3

View file

@ -182,11 +182,13 @@ public class File
* @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;
}
/**