garydgregory commented on code in PR #697:
URL: https://github.com/apache/commons-io/pull/697#discussion_r1829443400


##########
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());

Review Comment:
   As noted previously, use JUnit's `fail()` method.
   



##########
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:
   As previously noted, do use an import for 
`java.util.concurrent.CompletableFuture`.



##########
src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java:
##########
@@ -16,27 +16,26 @@
  */
 package org.apache.commons.io;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.function.Uncheck;
+import org.apache.commons.lang3.function.Consumers;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
+import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.io.filefilter.FileFilterUtils;
-import org.apache.commons.io.filefilter.IOFileFilter;
-import org.apache.commons.io.function.Uncheck;
-import org.apache.commons.lang3.function.Consumers;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Do not use star imports.
   
   Please run `mvn` by itself before you push. 
   
   In this case, you would have discovered this error:
   ```
   (imports) AvoidStarImport: Using the '.*' form of import should be avoided 
   ```
   



-- 
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]

Reply via email to