You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/27 09:47:13 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #14853: [improve][broker] reduce code duplication to avoid endless wait ``CompletableFuture``

eolivelli commented on a change in pull request #14853:
URL: https://github.com/apache/pulsar/pull/14853#discussion_r835880646



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -1196,13 +1111,16 @@ public void validateTopicOperation(TopicName topicName, TopicOperation operation
         }
     }
 
-    protected Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {
-        Throwable realCause = FutureUtil.unwrapCompletionException(ex);
-        if (realCause instanceof WebApplicationException) {
-            asyncResponse.resume(realCause);
-        } else {
-            asyncResponse.resume(new RestException(realCause));
+    public <T> T sync(Supplier<CompletableFuture<T>> supplier) {
+        try {
+            return supplier.get().get(config().getMetadataStoreOperationTimeoutSeconds(), SECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException ex) {
+            Throwable realCause = FutureUtil.unwrapCompletionException(ex);

Review comment:
       Please add something like this here:
   
   ```
   if (ex instanceof InterruptedException) {
       Thread.currentThread().interrupt();
   }
   ```




-- 
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-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org