From a8e29b73e655f143e3a25bd5dc02f079a3ec4414 Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 6 Jan 2023 12:27:54 +0800 Subject: [PATCH] fix: complete results future of selectedFiles Signed-off-by: tison --- .../src/main/java/io/korandoru/hawkeye/core/Selection.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hawkeye-core/src/main/java/io/korandoru/hawkeye/core/Selection.java b/hawkeye-core/src/main/java/io/korandoru/hawkeye/core/Selection.java index aebc32e5..27312dae 100644 --- a/hawkeye-core/src/main/java/io/korandoru/hawkeye/core/Selection.java +++ b/hawkeye-core/src/main/java/io/korandoru/hawkeye/core/Selection.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import lombok.Getter; import lombok.SneakyThrows; @@ -55,7 +56,7 @@ public Selection(File basedir, String[] included, String[] excluded, boolean use @SneakyThrows public String[] getSelectedFiles() { if (selectedFiles.isDone()) { - return selectedFiles.getNow(new String[0]); + return selectedFiles.get(0, TimeUnit.SECONDS); } final Path basePath = basedir.toPath(); @@ -93,7 +94,9 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); - return results.toArray(String[]::new); + + this.selectedFiles.complete(results.toArray(String[]::new)); + return selectedFiles.get(0, TimeUnit.SECONDS); } private static String[] buildExclusions(boolean useDefaultExcludes, String[] excludes, String[] overrides) {