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/25 00:43:44 UTC

[GitHub] [pulsar] mattisonchao commented on a change in pull request #14853: [improve][broker] Avoid use join to endless wait result.

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



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -623,12 +622,14 @@ public void validateBundleOwnership(NamespaceBundle bundle, boolean authoritativ
      */
     protected void validateTopicOwnership(TopicName topicName, boolean authoritative) {
         try {
-            validateTopicOwnershipAsync(topicName, authoritative).join();
-        } catch (CompletionException ce) {
-            if (ce.getCause() instanceof WebApplicationException) {
-                throw (WebApplicationException) ce.getCause();
+            validateTopicOwnershipAsync(topicName, authoritative)
+                    .get(config().getMetadataStoreOperationTimeoutSeconds(), SECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException ex) {
+            Throwable realCause = FutureUtil.unwrapCompletionException(ex);
+            if (realCause instanceof WebApplicationException) {
+                throw (WebApplicationException) realCause;
             } else {
-                throw new RestException(ce.getCause());
+                throw new RestException(realCause);
             }

Review comment:
       @lhotari  Yes, you are right, thanks for the suggestion.
   
   I need to say sorry, I didn't look closely at the other duplicate code because I found this issue while looking at other features at the time.
   So, I will solve this problem according to your suggestion.




-- 
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