Skip to content

Commit

Permalink
8322881: Method createTempFile() causes file copy permission issue wh…
Browse files Browse the repository at this point in the history
…en running through jtreg
  • Loading branch information
yaqsun committed Feb 22, 2024
1 parent 034324c commit d666698
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/jdk/java/nio/file/Files/CopyMoveVariations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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");

Expand Down

0 comments on commit d666698

Please sign in to comment.