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 19, 2024
1 parent 4ee537c commit 034324c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/jdk/java/nio/file/Files/CopyMoveVariations.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -142,14 +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(".");
try {
switch (type) {
case FILE ->
source = Files.createTempFile(Path.of("."), "file", "dat");
source = Files.createTempFile(dir, "file", "dat");
case DIR ->
source = Files.createTempDirectory(Path.of("."), "dir");
source = Files.createTempDirectory(dir, "dir");
case LINK -> {
linkTarget = Files.createTempFile(Path.of("."), "link", "target");
linkTarget = Files.createTempFile(dir, "link", "target");
Path link = Path.of("link");
source = Files.createSymbolicLink(link, linkTarget);
}
Expand All @@ -163,7 +164,7 @@ void op(OpType op, PathType type, String mode, boolean replaceExisting,
Files.setPosixFilePermissions(source, perms);

if (targetExists)
target = Files.createTempFile(Path.of("."), "file", "target");
target = Files.createTempFile(dir, "file", "target");
else
target = Path.of("target");

Expand Down

0 comments on commit 034324c

Please sign in to comment.