nodece commented on code in PR #15603:
URL: https://github.com/apache/pulsar/pull/15603#discussion_r873051695


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java:
##########
@@ -90,23 +84,20 @@ public void getTenants(@Suspended final AsyncResponse 
asyncResponse) {
             @ApiResponse(code = 404, message = "Tenant does not exist")})
     public void getTenantAdmin(@Suspended final AsyncResponse asyncResponse,
             @ApiParam(value = "The tenant name") @PathParam("tenant") String 
tenant) {
-        final String clientAppId = clientAppId();
-        try {
-            validateSuperUserAccess();
-        } catch (Exception e) {
-            asyncResponse.resume(e);
-        }
-
-        tenantResources().getTenantAsync(tenant).whenComplete((tenantInfo, e) 
-> {
-            if (e != null) {
-                log.error("[{}] Failed to get Tenant {}", clientAppId, 
e.getMessage());
-                asyncResponse.resume(new 
RestException(Status.INTERNAL_SERVER_ERROR, "Failed to get Tenant"));
-                return;
-            }
-            boolean response = tenantInfo.isPresent() ? 
asyncResponse.resume(tenantInfo.get())
-                    : asyncResponse.resume(new RestException(Status.NOT_FOUND, 
"Tenant does not exist"));
-            return;
-        });
+        validateSuperUserAccessAsync()
+                .thenCompose(__ -> tenantResources().getTenantAsync(tenant))
+                .thenApply(tenantInfo -> {
+                    if (!tenantInfo.isPresent()) {
+                        new RestException(Status.NOT_FOUND, "Tenant does not 
exist");
+                    }
+                    return tenantInfo.get();
+                })
+                .thenAccept(asyncResponse::resume)
+                .exceptionally(ex -> {
+                    log.error("[{}] Failed to get tenant admin {}", 
clientAppId(), ex);

Review Comment:
   If the tenant does not exist, we don't need to log an error.



-- 
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]

Reply via email to