codelipenghui commented on a change in pull request #14138:
URL: https://github.com/apache/pulsar/pull/14138#discussion_r800300867
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
##########
@@ -186,42 +190,25 @@ public void createTenant(@Suspended final AsyncResponse
asyncResponse,
public void updateTenant(@Suspended final AsyncResponse asyncResponse,
@ApiParam(value = "The tenant name") @PathParam("tenant") String
tenant,
@ApiParam(value = "TenantInfo") TenantInfoImpl newTenantAdmin) {
- try {
- validateSuperUserAccess();
- validatePoliciesReadOnlyAccess();
- validateClusters(newTenantAdmin);
- } catch (Exception e) {
- asyncResponse.resume(e);
- return;
- }
-
- final String clientAddId = clientAppId();
- tenantResources().getTenantAsync(tenant).thenAccept(tenantAdmin -> {
- if (!tenantAdmin.isPresent()) {
- asyncResponse.resume(new RestException(Status.NOT_FOUND,
"Tenant " + tenant + " not found"));
- return;
- }
- TenantInfo oldTenantAdmin = tenantAdmin.get();
- Set<String> newClusters = new
HashSet<>(newTenantAdmin.getAllowedClusters());
- canUpdateCluster(tenant, oldTenantAdmin.getAllowedClusters(),
newClusters).thenApply(r -> {
- tenantResources().updateTenantAsync(tenant, old ->
newTenantAdmin).thenAccept(done -> {
- log.info("Successfully updated tenant info {}", tenant);
+ validateSuperUserAccessAsync()
+ .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+ .thenCompose(__ -> validateClustersAsync(newTenantAdmin))
+ .thenCompose(__ -> tenantResources().getTenantAsync(tenant))
+ .thenCompose(tenantAdmin -> {
Review comment:
```suggestion
.thenCompose(tenantInfo -> {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]