You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/06/04 18:09:03 UTC

[GitHub] [pulsar] merlimat commented on a diff in pull request #15932: [fix] [admin] fix no matching code if the tenant already exists

merlimat commented on code in PR #15932:
URL: https://github.com/apache/pulsar/pull/15932#discussion_r889600730


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java:
##########
@@ -124,6 +124,12 @@ public void createTenant(@Suspended final AsyncResponse asyncResponse,
         validateSuperUserAccessAsync()
                 .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
                 .thenCompose(__ -> validateClustersAsync(tenantInfo))
+                .thenCompose(__ -> tenantResources().tenantExistsAsync(tenant))
+                .thenAccept(exist -> {
+                    if (exist) {
+                        throw new RestException(Status.CONFLICT, "Tenant already exist");
+                    }
+                })

Review Comment:
   We should also add a unit test to ensure the exception is the expected one (and that later on, the behavior will not be broken). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org