Skip to content

Commit

Permalink
Different method of waiting for the table cache load, using a separat…
Browse files Browse the repository at this point in the history
…e future with a timeout.
  • Loading branch information
piotrczarnas committed Jun 26, 2024
1 parent 49e8599 commit a21c3a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,8 @@ public CompletableFuture<Boolean> getQueueEmptyFuture(Long waitTimeoutMillisecon
.thenApply(result -> true);

if (waitTimeoutMilliseconds != null) {
booleanCompletableFuture = booleanCompletableFuture.completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);

// CompletableFuture<Boolean> timeoutFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);
// booleanCompletableFuture = (CompletableFuture<Boolean>)(CompletableFuture<?>)CompletableFuture.anyOf(booleanCompletableFuture, timeoutFuture);

CompletableFuture<Boolean> timeoutFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);
booleanCompletableFuture = (CompletableFuture<Boolean>)(CompletableFuture<?>)CompletableFuture.anyOf(booleanCompletableFuture, timeoutFuture);
}

return booleanCompletableFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,8 @@ public CompletableFuture<Boolean> getQueueEmptyFuture(Long waitTimeoutMillisecon
.thenApply(result -> true);

if (waitTimeoutMilliseconds != null) {
booleanCompletableFuture = booleanCompletableFuture.completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);

// CompletableFuture<Boolean> timeoutFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);
// booleanCompletableFuture = (CompletableFuture<Boolean>)(CompletableFuture<?>)CompletableFuture.anyOf(booleanCompletableFuture, timeoutFuture);

CompletableFuture<Boolean> timeoutFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, waitTimeoutMilliseconds, TimeUnit.MILLISECONDS);
booleanCompletableFuture = (CompletableFuture<Boolean>)(CompletableFuture<?>)CompletableFuture.anyOf(booleanCompletableFuture, timeoutFuture);
}

return booleanCompletableFuture;
Expand Down

0 comments on commit a21c3a2

Please sign in to comment.