Skip to content

Commit 985ddc8

Browse files
committed
Improve executor termination in FileUtilsTest
Replaces busy-wait loop with assertTrue using awaitTermination for better test reliability and readability in testDeleteDirectoryOnIOException.
1 parent d42bbbb commit 985ddc8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static java.util.concurrent.Executors.newFixedThreadPool;
3535
import static java.util.concurrent.Executors.newSingleThreadExecutor;
3636
import static java.util.concurrent.TimeUnit.MILLISECONDS;
37+
import static java.util.concurrent.TimeUnit.SECONDS;
3738
import static org.junit.jupiter.api.Assertions.assertEquals;
3839
import static org.junit.jupiter.api.Assertions.assertFalse;
3940
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -116,8 +117,7 @@ void testDeleteDirectoryOnIOException() throws Exception {
116117
ExecutorService executor = newSingleThreadExecutor();
117118
executor.submit(this::testDeleteDirectoryOnIOException0);
118119
shutdown(executor);
119-
while (!executor.isTerminated()) {
120-
}
120+
assertTrue(executor.awaitTermination(5, SECONDS));
121121
}
122122

123123
Void testDeleteDirectoryOnIOException0() throws Exception {

0 commit comments

Comments
 (0)