This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new bb4cb31  Fix potential http get hangs in the Pulsar Admin (#9203)
bb4cb31 is described below

commit bb4cb3125d92d3c59224524c9d59cff8f3cd7324
Author: lipenghui <[email protected]>
AuthorDate: Thu Jan 14 14:02:11 2021 +0800

    Fix potential http get hangs in the Pulsar Admin (#9203)
    
    ### Motivation
    
    Currently, for the HTTP async get method, we pass a callback and return a 
future. This is confusing which one is the right result. And if exception 
throws, will return a future that complete with exception but the callback have 
not been called. All the caller of the `asyncGetRequest` handles the callback, 
not the returned future, this will lead a potential hangs in the Pulsar Admin 
since the callback might never be called.
    
    ### Modifications
    
    Change the `asyncGetRequest` method to only handle the callback and use 
`void` as the return type.
---
 .../org/apache/pulsar/client/admin/internal/BaseResource.java     | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
 
b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
index eb08f93..10126d0 100644
--- 
a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
+++ 
b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
@@ -22,7 +22,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
 import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.ServiceUnavailableException;
@@ -46,7 +45,6 @@ import org.apache.pulsar.client.api.Authentication;
 import org.apache.pulsar.client.api.AuthenticationDataProvider;
 import org.apache.pulsar.client.api.PulsarClientException;
 import org.apache.pulsar.common.policies.data.ErrorData;
-import org.apache.pulsar.common.util.FutureUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -161,11 +159,11 @@ public abstract class BaseResource {
         return future;
     }
 
-    public <T> Future<T> asyncGetRequest(final WebTarget target, 
InvocationCallback<T> callback) {
+    public <T> void asyncGetRequest(final WebTarget target, 
InvocationCallback<T> callback) {
         try {
-            return request(target).async().get(callback);
+            request(target).async().get(callback);
         } catch (PulsarAdminException cae) {
-            return FutureUtil.failedFuture(cae);
+            callback.failed(cae);
         }
     }
 

Reply via email to