Skip to content

Commit

Permalink
fix un-correct tips for create topic error when namespace not exist (a…
Browse files Browse the repository at this point in the history
…pache#9223)

Fixes apache#9220

Motivation
fix un-correct tips for create topic error when namespace not exist
  • Loading branch information
aloyszhang authored Jan 18, 2021
1 parent 66576fa commit 39dc24b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ protected void validateGlobalNamespaceOwnership(String property, String namespac
} catch (IllegalArgumentException e) {
throw new RestException(Status.PRECONDITION_FAILED, "Tenant name or namespace is not valid");
} catch (RestException re) {
if (re.getResponse().getStatus() == Status.NOT_FOUND.getStatusCode()) {
throw new RestException(Status.NOT_FOUND, "Namespace not found");
}
throw new RestException(Status.PRECONDITION_FAILED, "Namespace does not have any clusters configured");
} catch (Exception e) {
log.warn("Failed to validate global cluster configuration : ns={} emsg={}", namespace, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,18 @@ public void testPersistentTopicExpireMessageOnParitionTopic() throws Exception {

}

@Test
public void testNamespaceNotExist() throws Exception {
final String nonPartitionedtopic = "persistent://prop-xyz/no-exist/non-partitioned-topic";
try {
admin.topics().createNonPartitionedTopic(nonPartitionedtopic);
fail("should falied for namespaces not exist");
} catch (Exception e) {
assertTrue(e instanceof NotFoundException);
assertTrue(e.getMessage().equals("Namespace not found"));
}
}

@Test
public void testPersistentTopicCreation() throws Exception {
final String nonPartitionedtopic = "persistent://prop-xyz/ns1/non-partitioned-topic";
Expand Down

0 comments on commit 39dc24b

Please sign in to comment.