8282397: createTempFile method of java.io.File is failing when called with suffix of spaces character

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2022-03-09 16:03:46 +00:00 committed by Henry Jen
parent 8d456ac0ec
commit 98d54e8eb2

View file

@ -333,9 +333,12 @@ class WinNTFileSystem extends FileSystem {
// is a ":" at position 1 and the first character is not a letter
String pathname = f.getPath();
int lastColon = pathname.lastIndexOf(":");
if (lastColon > 1 ||
(lastColon == 1 && !isLetter(pathname.charAt(0))))
return true;
// Valid if there is no ":" present or if the last ":" present is
// at index 1 and the first character is a latter
if (lastColon < 0 ||
(lastColon == 1 && isLetter(pathname.charAt(0))))
return false;
// Invalid if path creation fails
Path path = null;