This is an automated email from the ASF dual-hosted git repository. penghui pushed a commit to branch branch-2.8 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 718bd679230f6c52f0a8762e1b55f96b3b00ebf0 Author: Jiwei Guo <[email protected]> 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 0cec819..bd23a37 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 @@ -50,7 +50,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 8e0f5b6..17fd417 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 @@ -1858,4 +1858,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")); + } + } }
