You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2022/03/18 07:59:29 UTC

[pulsar] 07/16: Fixed 404 error msg not being returned correctly using http lookup. (#14677)

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

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

commit 08eceb74175f1c1deb78c6cc0bfbf77646bff635
Author: Jiwei Guo <te...@apache.org>
AuthorDate: Tue Mar 15 22:15:44 2022 +0800

    Fixed 404 error msg not being returned correctly using http lookup. (#14677)
    
    (cherry picked from commit 9a88508426cd2f6baf8d25a225f5f27de5bc1a7a)
---
 .../java/org/apache/pulsar/broker/web/RestException.java    |  6 +++++-
 .../pulsar/broker/service/PersistentTopicE2ETest.java       | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/RestException.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/RestException.java
index 2c01a7f..8ff016c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/RestException.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/RestException.java
@@ -49,7 +49,11 @@ public class RestException extends WebApplicationException {
     }
 
     public RestException(int code, String message) {
-        super(message, Response.status(code).entity(new ErrorData(message)).type(MediaType.APPLICATION_JSON).build());
+        super(message, Response
+                .status(code, message)
+                .entity(new ErrorData(message))
+                .type(MediaType.APPLICATION_JSON)
+                .build());
     }
 
     public RestException(Throwable t) {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java
index daf0ed7..9de664f 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java
@@ -1879,4 +1879,17 @@ public class PersistentTopicE2ETest extends BrokerTestBase {
 
         assertEquals(admin.topics().getStats(topicName).getPublishers().size(), 1);
     }
+
+    @Test
+    public void testHttpLookupWithNotFoundError() throws Exception {
+        stopBroker();
+        isTcpLookup = false;
+        setup();
+        try {
+            pulsarClient.newProducer().topic("unknownTenant/unknownNamespace/testNamespaceNotFound").create();
+        } catch (Exception ex) {
+            assertTrue(ex instanceof PulsarClientException.NotFoundException);
+            assertTrue(ex.getMessage().contains("Namespace not found"));
+        }
+    }
 }