8160220: (fs) Tests in jdk/test/java/nio/file/WatchService leave directory trees behind
Create temporary files by default in a scratch directory. Reviewed-by: alanb, chegar
This commit is contained in:
parent
14d4754bdd
commit
eba2a20a2b
@ -32,6 +32,7 @@ import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.WatchService;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -49,7 +50,8 @@ public class DeleteInterference {
|
||||
* directory.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
Path dir = Files.createTempDirectory("DeleteInterference");
|
||||
Path testDir = Paths.get(System.getProperty("test.dir", "."));
|
||||
Path dir = Files.createTempDirectory(testDir, "DeleteInterference");
|
||||
ExecutorService pool = Executors.newCachedThreadPool();
|
||||
try {
|
||||
Future<?> task1 = pool.submit(() -> openAndCloseWatcher(dir));
|
||||
@ -58,7 +60,6 @@ public class DeleteInterference {
|
||||
task2.get();
|
||||
} finally {
|
||||
pool.shutdown();
|
||||
deleteFileTree(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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
|
||||
@ -27,11 +27,11 @@
|
||||
* an outstanding I/O operation on directory completes after the
|
||||
* directory has been closed
|
||||
*/
|
||||
|
||||
import java.nio.file.ClosedWatchServiceException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
@ -50,8 +50,8 @@ public class LotsOfCancels {
|
||||
// one to bash on cancel, the other to poll the events
|
||||
ExecutorService pool = Executors.newCachedThreadPool();
|
||||
try {
|
||||
Path top = Files.createTempDirectory("LotsOfCancels");
|
||||
top.toFile().deleteOnExit();
|
||||
Path testDir = Paths.get(System.getProperty("test.dir", "."));
|
||||
Path top = Files.createTempDirectory(testDir, "LotsOfCancels");
|
||||
for (int i=1; i<=16; i++) {
|
||||
Path dir = Files.createDirectory(top.resolve("dir-" + i));
|
||||
WatchService watcher = FileSystems.getDefault().newWatchService();
|
||||
@ -114,6 +114,4 @@ public class LotsOfCancels {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user