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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -3218,7 +3219,7 @@ public boolean checkSubscriptionTypesEnable(SubType 
subType) throws Exception {
                 if (topicPolicies == null) {
                     return checkNsAndBrokerSubscriptionTypesEnable(topicName, 
subType);
                 } else {
-                    if (topicPolicies.getSubscriptionTypesEnabled().isEmpty()) 
{
+                    if 
(CollectionUtils.isEmpty(topicPolicies.getSubscriptionTypesEnabled())) {

Review comment:
       `topicPolicies.getSubscriptionTypesEnabled()` default value is `empty 
list`, when can it become `null`?
   
https://github.com/apache/pulsar/blob/94736a43f1b9a6d1db75936032b94eb9a11b9c0d/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/TopicPolicies.java#L47-L48
   In addition, it is recommended to combine the two judgments as below:
   ```
   if (topicPolicies == null || 
CollectionUtils.isEmpty(topicPolicies.getSubscriptionTypesEnabled())) {
       return checkNsAndBrokerSubscriptionTypesEnable(topicName, subType);
   } else {
       return topicPolicies.getSubscriptionTypesEnabled().contains(subType);
   }
   ```




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