From d66669839b5f81bb19a61446da5aa9b6b7963497 Mon Sep 17 00:00:00 2001 From: sunyaqi Date: Thu, 22 Feb 2024 14:16:11 +0800 Subject: [PATCH] 8322881: Method createTempFile() causes file copy permission issue when running through jtreg --- test/jdk/java/nio/file/Files/CopyMoveVariations.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/nio/file/Files/CopyMoveVariations.java b/test/jdk/java/nio/file/Files/CopyMoveVariations.java index 49493b8f2dff3..bf43c3ee36136 100644 --- a/test/jdk/java/nio/file/Files/CopyMoveVariations.java +++ b/test/jdk/java/nio/file/Files/CopyMoveVariations.java @@ -72,7 +72,7 @@ enum PathType { static { Path tmp = null; try { - tmp = Files.createTempFile("this", "that"); + tmp = Files.createTempFile(Path.of("."), "this", "that"); SUPPORTS_POSIX_PERMISSIONS = Files.getFileStore(tmp).supportsFileAttributeView("posix"); } catch (IOException cause) { @@ -142,15 +142,15 @@ void op(OpType op, PathType type, String mode, boolean replaceExisting, Path source = null; Path target = null; Path linkTarget = null; - Path dir = Path.of("."); + Path current = Path.of("."); try { switch (type) { case FILE -> - source = Files.createTempFile(dir, "file", "dat"); + source = Files.createTempFile(current, "file", "dat"); case DIR -> - source = Files.createTempDirectory(dir, "dir"); + source = Files.createTempDirectory(current, "dir"); case LINK -> { - linkTarget = Files.createTempFile(dir, "link", "target"); + linkTarget = Files.createTempFile(current, "link", "target"); Path link = Path.of("link"); source = Files.createSymbolicLink(link, linkTarget); } @@ -164,7 +164,7 @@ void op(OpType op, PathType type, String mode, boolean replaceExisting, Files.setPosixFilePermissions(source, perms); if (targetExists) - target = Files.createTempFile(dir, "file", "target"); + target = Files.createTempFile(current, "file", "target"); else target = Path.of("target");