aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Balao <mbalao@openjdk.org>2022-03-09 21:16:49 +0000
committerChristoph Langer <clanger@openjdk.org>2022-04-08 07:42:40 +0200
commit16a9af0a12329871e1bce30e10c2c3f7bf5d4942 (patch)
tree4c1b67d5e4a796a465877e962554921c34f6782a
parentab8d162abb4f2ebb6e5e234cc7eb15bf96ef8afe (diff)
downloadjdk11-16a9af0a12329871e1bce30e10c2c3f7bf5d4942.tar.gz
8282397: createTempFile method of java.io.File is failing when called with suffix of spaces character
Reviewed-by: mbaesken Backport-of: d48181536fa9b99f01fc80f8adb73777ec6ffa58
-rw-r--r--src/java.base/windows/classes/java/io/WinNTFileSystem.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
index f912fa0793..a45fd3e7f8 100644
--- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java
+++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
@@ -331,9 +331,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;