yuruguo commented on a change in pull request #12392:
URL: https://github.com/apache/pulsar/pull/12392#discussion_r738120102



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java
##########
@@ -1698,8 +1698,8 @@ public void testSubscriptionTypesEnabled() throws 
PulsarAdminException, PulsarCl
         }
 
         // clear all namespace subType enabled, add failover to broker.conf 
and sub with shared will fail
-        subscriptionTypes.clear();
-        admin.namespaces().setSubscriptionTypesEnabled(namespace, 
subscriptionTypes);
+        admin.namespaces().removeSubscriptionTypesEnabled(namespace);
+        
assertEquals(admin.namespaces().getSubscriptionTypesEnabled(namespace), 
Sets.newHashSet());

Review comment:
       I don't think we need to be consistent with other remove interfaces (set 
the `null` value), because the policy `subscription_types_enabled` is different 
from the others. The details are as follows:
   
   1. The other remove interfaces can set the `null` value because the 
corresponding policy's default value is `null`, 
   for example: `removeNamespaceMessageTTL` interface and corresponding policy 
`message_ttl_in_seconds`
   
https://github.com/apache/pulsar/blob/030358e515df20556a200cfe3f88286313d92be1/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java#L306-L310
   
https://github.com/apache/pulsar/blob/030358e515df20556a200cfe3f88286313d92be1/pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/Policies.java#L61
   But `removeSubscriptionTypesEnabled` interface and corresponding policy 
`subscription_types_enabled` is not the case, its default value is `empty Set`, 
so we could set `Sets.newHashSet() ` instead of `null`
   
https://github.com/apache/pulsar/blob/030358e515df20556a200cfe3f88286313d92be1/pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/Policies.java#L122
   
   2. If we set `null` in this remove interface - 
`removeSubscriptionTypesEnabled`, there will be NPE in many places, such as 
`L2445` and `L2435`:
   
https://github.com/apache/pulsar/blob/030358e515df20556a200cfe3f88286313d92be1/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L2440-L2451
   
https://github.com/apache/pulsar/blob/030358e515df20556a200cfe3f88286313d92be1/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L2431-L2437
   
   In summary, there is no problem setting `empty Set` instead of `null`.




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