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

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


The following commit(s) were added to refs/heads/master by this push:
     new f258e6e  Handle null redirection url with error-message at broker 
(#1418)
f258e6e is described below

commit f258e6e29cbf93170859fdfe26250bf0ca24d41b
Author: Rajan Dhabalia <[email protected]>
AuthorDate: Tue Mar 27 16:00:10 2018 -0700

    Handle null redirection url with error-message at broker (#1418)
---
 .../java/org/apache/pulsar/broker/lookup/TopicLookup.java     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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 eed3681..00613f2 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.apache.pulsar.common.util.Codec;
 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 class TopicLookup extends PulsarWebResource {
                 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 class TopicLookup extends PulsarWebResource {
                             }
                             // 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));

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to