garydgregory commented on code in PR #697:
URL: https://github.com/apache/commons-io/pull/697#discussion_r1829957820
##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -222,4 +226,47 @@ public void testListFilesWithDeletion() throws IOException
{
assertEquals(4, list.size());
}
+ @Test
+ public void testListFilesWithDeletionThreaded() throws
java.util.concurrent.ExecutionException, InterruptedException {
Review Comment:
You don't need a fully qualified class name here.
##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -222,4 +226,47 @@ public void testListFilesWithDeletion() throws IOException
{
assertEquals(4, list.size());
}
+ @Test
+ public void testListFilesWithDeletionThreaded() throws
java.util.concurrent.ExecutionException, InterruptedException {
+ // test for IO-856
+ // create random directory in tmp, create the directory if it does not
exist
+ final File dir = FileUtils.getTempDirectory();
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ fail("could not create image file path: " +
dir.getAbsolutePath());
+ }
+ }
+ final int waitTime = 10000;
+ final CompletableFuture<Void> c1 =
java.util.concurrent.CompletableFuture.runAsync(() -> {
+ long endTime = System.currentTimeMillis() + waitTime;
+ while (System.currentTimeMillis() < endTime) {
+ final File file = new File(dir.getAbsolutePath(),
java.util.UUID.randomUUID() + ".deletetester");
+ file.deleteOnExit();
+ try {
+ new
BufferedOutputStream(java.nio.file.Files.newOutputStream(file.toPath())).write("TEST".getBytes(java.nio.charset.StandardCharsets.UTF_8));
Review Comment:
You don't need a fully qualified class name here.
##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -222,4 +226,47 @@ public void testListFilesWithDeletion() throws IOException
{
assertEquals(4, list.size());
}
+ @Test
+ public void testListFilesWithDeletionThreaded() throws
java.util.concurrent.ExecutionException, InterruptedException {
+ // test for IO-856
+ // create random directory in tmp, create the directory if it does not
exist
+ final File dir = FileUtils.getTempDirectory();
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ fail("could not create image file path: " +
dir.getAbsolutePath());
+ }
+ }
+ final int waitTime = 10000;
+ final CompletableFuture<Void> c1 =
java.util.concurrent.CompletableFuture.runAsync(() -> {
Review Comment:
You don't need a fully qualified class name here.
##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -211,7 +214,8 @@ public void testListFilesWithDeletion() throws IOException {
final String[] extensions = {"xml", "txt"};
final List<File> list;
final File xFile = new File(temporaryFolder, "x.xml");
- xFile.createNewFile();
+ if(!xFile.createNewFile())
+ fail("could not create test file: " + xFile);
Review Comment:
Always use a block.
##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -222,4 +221,47 @@ public void testListFilesWithDeletion() throws IOException
{
assertEquals(4, list.size());
}
+ @Test
+ public void testListFilesWithDeletionThreaded() throws
java.util.concurrent.ExecutionException, InterruptedException {
+ // test for IO-856
+ // create random directory in tmp, create the directory if it does not
exist
+ final File dir = FileUtils.getTempDirectory();
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ throw new RuntimeException("could not create image file path:
" + dir.getAbsolutePath());
+ }
+ }
+ final int waitTime = 10000;
+ final CompletableFuture<Void> c1 =
java.util.concurrent.CompletableFuture.runAsync(() -> {
+ long endTime = System.currentTimeMillis() + waitTime;
+ while (System.currentTimeMillis() < endTime) {
+ final File file = new File(dir.getAbsolutePath(),
java.util.UUID.randomUUID() + ".deletetester");
+ file.deleteOnExit();
+ try {
+ new
BufferedOutputStream(java.nio.file.Files.newOutputStream(file.toPath())).write("TEST".getBytes(java.nio.charset.StandardCharsets.UTF_8));
+ } catch (Exception e) {
+ fail("could not create test file: " +
file.getAbsolutePath(), e);
+ }
+ if (!file.delete()) {
+ fail("could not delete test file: " +
file.getAbsolutePath());
+ }
+ }
+ });
+
+ final CompletableFuture<Void> c2 =
java.util.concurrent.CompletableFuture.runAsync(() -> {
Review Comment:
You don't need a fully qualified class name here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]