gaoran10 commented on a change in pull request #13837: URL: https://github.com/apache/pulsar/pull/13837#discussion_r788306929
########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/util/RetryUtil.java ########## @@ -43,26 +43,28 @@ executeWithRetry(supplier, backoff, scheduledExecutorService, callback)); } - private static <T> void executeWithRetry(Supplier<T> supplier, Backoff backoff, + private static <T> void executeWithRetry(Supplier<CompletableFuture<T>> supplier, Backoff backoff, ScheduledExecutorService scheduledExecutorService, CompletableFuture<T> callback) { - try { - T result = supplier.get(); - callback.complete(result); - } catch (Exception e) { - long next = backoff.next(); - boolean isMandatoryStop = backoff.isMandatoryStopMade(); - if (isMandatoryStop) { - callback.completeExceptionally(e); - } else { - if (log.isDebugEnabled()) { - log.debug("execute with retry fail, will retry in {} ms", next, e); + if (supplier == null || supplier.get() == null) { + throw new RuntimeException("Miss retry execution supplier."); + } + supplier.get().whenComplete((result, e) -> { + if (e != null) { + long next = backoff.next(); + boolean isMandatoryStop = backoff.isMandatoryStopMade(); + if (isMandatoryStop) { + callback.completeExceptionally(e); + } else { + log.warn("Execution with retry fail, because of {}, will retry in {} ms", e.getMessage(), next); + scheduledExecutorService.schedule(() -> Review comment: I don't want to use the retry mechanism to resolve the problem, change the synchronous reader method to be asynchronous, it will not block the executor thread of the PulsarService. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org