Skip to content

Commit

Permalink
[Broker] Change create topic return error to Status.BAD_REQUEST (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
congbobo184 authored Jan 18, 2022
1 parent 0a046b9 commit 2262a5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ protected void validateAdminAndClientPermission() {

protected void validateCreateTopic(TopicName topicName) {
if (isTransactionInternalName(topicName)) {
log.warn("Try to create a topic in the system topic format! {}", topicName);
throw new RestException(Status.CONFLICT, "Cannot create topic in system topic format!");
log.warn("Forbidden to create transaction internal topic: {}", topicName);
throw new RestException(Status.BAD_REQUEST, "Cannot create topic in system topic format!");
}
}

Expand Down Expand Up @@ -3754,7 +3754,7 @@ private Topic getTopicReference(TopicName topicName) {
throw e;
} catch (Exception e) {
if (e.getCause() instanceof NotAllowedException) {
throw new RestException(Status.CONFLICT, e.getCause());
throw new RestException(Status.BAD_REQUEST, e.getCause());
}
throw new RestException(e.getCause() == null ? e : e.getCause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,23 @@ public void testCreateTransactionSystemTopic() throws Exception {
try {
admin.topics().getSubscriptions(topicName);
fail();
} catch (PulsarAdminException.ConflictException e) {
} catch (PulsarAdminException e) {
assertEquals(e.getMessage(), "Can not create transaction system topic " + topicName);
}

// can't create transaction system topic
try {
admin.topics().createPartitionedTopic(topicName, 3);
fail();
} catch (PulsarAdminException.ConflictException e) {
} catch (PulsarAdminException e) {
assertEquals(e.getMessage(), "Cannot create topic in system topic format!");
}

// can't create transaction system topic
try {
admin.topics().createNonPartitionedTopic(topicName);
fail();
} catch (PulsarAdminException.ConflictException e) {
} catch (PulsarAdminException e) {
assertEquals(e.getMessage(), "Cannot create topic in system topic format!");
}
}
Expand Down

0 comments on commit 2262a5d

Please sign in to comment.