You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2022/06/14 01:48:17 UTC
[pulsar] branch master updated: [fix][admin] Release LookupRequestSemaphore before returning data. (#15974)
This is an automated email from the ASF dual-hosted git repository.
technoboy 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 56765e9936a [fix][admin] Release LookupRequestSemaphore before returning data. (#15974)
56765e9936a is described below
commit 56765e9936a93f1c5c04cf44d220a088ee1efa02
Author: Lei Zhiyuan <le...@gmail.com>
AuthorDate: Tue Jun 14 09:48:09 2022 +0800
[fix][admin] Release LookupRequestSemaphore before returning data. (#15974)
---
.../java/org/apache/pulsar/broker/lookup/TopicLookupBase.java | 11 ++++-------
.../java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java | 2 +-
.../java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java | 2 +-
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
index d985de70d15..3c29ef1597a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
@@ -29,7 +29,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import javax.ws.rs.Encoded;
import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.broker.PulsarService;
@@ -127,8 +126,12 @@ public class TopicLookupBase extends PulsarWebResource {
log.debug("Lookup succeeded for topic {} -- broker: {}", topicName,
result.getLookupData());
}
+ pulsar().getBrokerService().getLookupRequestSemaphore().release();
return result.getLookupData();
}
+ }).exceptionally(ex->{
+ pulsar().getBrokerService().getLookupRequestSemaphore().release();
+ throw FutureUtil.wrapToCompletionException(ex);
});
});
}
@@ -336,12 +339,6 @@ public class TopicLookupBase extends PulsarWebResource {
return lookupfuture;
}
- protected void completeLookupResponseExceptionally(AsyncResponse asyncResponse, Throwable t) {
- pulsar().getBrokerService().getLookupRequestSemaphore().release();
- Throwable cause = FutureUtil.unwrapCompletionException(t);
- asyncResponse.resume(cause);
- }
-
protected TopicName getTopicName(String topicDomain, String tenant, String cluster, String namespace,
@Encoded String encodedTopic) {
String decodedName = Codec.decode(encodedTopic);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
index b1015d9e063..064a393da65 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
@@ -77,7 +77,7 @@ public class TopicLookup extends TopicLookupBase {
if (log.isDebugEnabled()) {
log.debug("Failed to check exist for topic {} when lookup", topicName, ex);
}
- completeLookupResponseExceptionally(asyncResponse, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
index b343a92a42c..592acfa2629 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
@@ -64,7 +64,7 @@ public class TopicLookup extends TopicLookupBase {
if (log.isDebugEnabled()) {
log.debug("Failed to check exist for topic {} when lookup", topicName, ex);
}
- completeLookupResponseExceptionally(asyncResponse, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
}