massakam commented on a change in pull request #10790: URL: https://github.com/apache/pulsar/pull/10790#discussion_r645684070
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java ########## @@ -177,12 +178,28 @@ public boolean isReplicated() { return replicatedSubscriptionSnapshotCache != null; } - void setReplicated(boolean replicated) { - this.replicatedSubscriptionSnapshotCache = replicated - ? new ReplicatedSubscriptionSnapshotCache(subName, - topic.getBrokerService().pulsar().getConfiguration() - .getReplicatedSubscriptionsSnapshotMaxCachedPerSubscription()) - : null; + public void setReplicated(boolean replicated) { + ServiceConfiguration config = topic.getBrokerService().getPulsar().getConfig(); + + if (!replicated || !config.isEnableReplicatedSubscriptions()) { + this.replicatedSubscriptionSnapshotCache = null; + } else if (this.replicatedSubscriptionSnapshotCache == null) { + this.replicatedSubscriptionSnapshotCache = new ReplicatedSubscriptionSnapshotCache(subName, + config.getReplicatedSubscriptionsSnapshotMaxCachedPerSubscription()); + } + + if (this.cursor != null) { + Map<String, Long> properties = this.cursor.getProperties(); Review comment: Fixed. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org