merlimat closed pull request #1418: Handle null redirection url with
error-message at broker
URL: https://github.com/apache/incubator-pulsar/pull/1418
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
index eed36810e..00613f265 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
@@ -18,6 +18,7 @@
*/
package org.apache.pulsar.broker.lookup;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.pulsar.common.api.Commands.newLookupErrorResponse;
import static org.apache.pulsar.common.api.Commands.newLookupResponse;
@@ -56,6 +57,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import dlshade.org.apache.commons.lang3.StringUtils;
import io.netty.buffer.ByteBuf;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
@@ -123,9 +125,10 @@ public void lookupTopicAsync(@PathParam("topic-domain")
String topicDomain,
try {
String redirectUrl = isRequestHttps() ?
result.getLookupData().getHttpUrlTls()
: result.getLookupData().getHttpUrl();
+ checkNotNull(redirectUrl, "Redirected cluster's service
url is not configured");
redirect = new
URI(String.format("%s%s%s?authoritative=%s", redirectUrl,
"/lookup/v2/destination/",
topic.getLookupName(), newAuthoritative));
- } catch (URISyntaxException e) {
+ } catch (URISyntaxException | NullPointerException e) {
log.error("Error in preparing redirect url for {}: {}",
topic, e.getMessage(), e);
completeLookupResponseExceptionally(asyncResponse, e);
return;
@@ -239,6 +242,12 @@ public String
getNamespaceBundle(@PathParam("topic-domain") String topicDomain,
}
// if peer-cluster-data is present it means
namespace is owned by that peer-cluster and
// request should be redirect to the peer-cluster
+ if
(StringUtils.isBlank(peerClusterData.getBrokerServiceUrl())
+ &&
StringUtils.isBlank(peerClusterData.getBrokerServiceUrl())) {
+ validationFuture.complete(
+
newLookupErrorResponse(ServerError.MetadataError, "Redirected cluster's
brokerService url is not configured", requestId));
+ return;
+ }
validationFuture.complete(newLookupResponse(peerClusterData.getBrokerServiceUrl(),
peerClusterData.getBrokerServiceUrlTls(),
true, LookupType.Redirect, requestId,
false));
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services