Skip to content

Commit

Permalink
Wait for file writer complete (opensource4you#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinghongfang authored Aug 10, 2022
1 parent 0d62821 commit ae0147a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public static String execute(final Argument param) throws InterruptedException,
.sum(),
tracker));

fileWriter.ifPresent(CompletableFuture::runAsync);
var fileWriterFuture =
fileWriter.map(CompletableFuture::runAsync).orElse(CompletableFuture.completedFuture(null));

CompletableFuture.runAsync(
() -> {
Expand All @@ -191,6 +192,7 @@ public static String execute(final Argument param) throws InterruptedException,

consumerThreads.forEach(AbstractThread::waitForDone);
tracker.waitForDone();
fileWriterFuture.join();
return param.topic;
}

Expand Down

0 comments on commit ae0147a

Please sign in to comment.