nicoloboschi commented on code in PR #19258:
URL: https://github.com/apache/pulsar/pull/19258#discussion_r1072437151


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -258,4 +259,25 @@ public static CompletionException 
wrapToCompletionException(Throwable throwable)
             return new CompletionException(throwable);
         }
     }
+
+    /**
+     * Creates a new {@link CompletableFuture} instance catching
+     * potential exceptions and completing the future exceptionally.
+     *
+     * @param runnable the runnable to execute
+     * @param executor  the executor to use for executing the runnable
+     * @param completableFuture  the future to complete in case of exceptions
+     * @return
+     */
+
+    public static void safeRunAsync(Runnable runnable,
+                                    Executor executor,
+                                    CompletableFuture completableFuture) {
+        CompletableFuture
+                .runAsync(runnable, executor)
+                .exceptionally((throwable) -> {
+                    completableFuture.completeExceptionally(throwable);

Review Comment:
   In the Pulsar codebase `exceptionallyAsync` is rarely used. I'd like to keep 
a coherent behaviour



##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -258,4 +259,25 @@ public static CompletionException 
wrapToCompletionException(Throwable throwable)
             return new CompletionException(throwable);
         }
     }
+
+    /**
+     * Creates a new {@link CompletableFuture} instance catching

Review Comment:
   fixed



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to