mattisonchao commented on a change in pull request #13970:
URL: https://github.com/apache/pulsar/pull/13970#discussion_r794991202



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -2720,25 +2746,55 @@ private void updatePolicies(NamespaceName ns, 
Function<Policies, Policies> updat
        }
    }
 
-    protected void internalSetNamespaceResourceGroup(String rgName) {
-        validateNamespacePolicyOperation(namespaceName, 
PolicyName.RESOURCEGROUP, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-
-        if (rgName != null) {
-            // check resourcegroup exists.
-            try {
-                if (!resourceGroupResources().resourceGroupExists(rgName)) {
-                    throw new RestException(Status.PRECONDITION_FAILED, 
"ResourceGroup does not exist");
-                }
-            } catch (Exception e) {
-                log.error("[{}] Invalid ResourceGroup {}: {}", clientAppId(), 
rgName, e);
-                throw new RestException(e);
-            }
-        }
 
-        internalSetPolicies("resource_group_name", rgName);
+    protected void internalGetNamespaceResourceGroup(AsyncResponse 
asyncResponse, String tenant, String namespace) {
+        validateNamespacePolicyOperationAsync(NamespaceName.get(tenant, 
namespace),
+                PolicyName.RESOURCEGROUP, PolicyOperation.READ)
+                .thenCompose(__ -> getNamespacePoliciesAsync(namespaceName)
+                        .thenAccept(policies -> 
asyncResponse.resume(policies.resource_group_name)))

Review comment:
       I think we don't need to add ``whenComplete `` to increase code 
complexity. So I add successful log info in ``thenAccept``.




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