From a4c19d9e66d867ee351bd63592dcc1fe002d46b3 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Thu, 24 Mar 2022 16:57:12 +0300 Subject: [PATCH] 8282397: createTempFile method of java.io.File is failing when called with suffix of spaces character Reviewed-by: bae Backport-of: d48181536fa9b99f01fc80f8adb73777ec6ffa58 --- jdk/src/windows/classes/java/io/Win32FileSystem.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jdk/src/windows/classes/java/io/Win32FileSystem.java b/jdk/src/windows/classes/java/io/Win32FileSystem.java index 2e62cf804d..c71e524ff6 100644 --- a/jdk/src/windows/classes/java/io/Win32FileSystem.java +++ b/jdk/src/windows/classes/java/io/Win32FileSystem.java @@ -359,9 +359,12 @@ class Win32FileSystem 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;