From db24ff0958a2f606f222c1b90aba9032b310eef8 Mon Sep 17 00:00:00 2001 From: feynmanlin Date: Thu, 3 Jun 2021 02:28:50 +0800 Subject: [PATCH] Avoid warning logs on topic policies not present (#10785) --- .../pulsar/broker/service/BacklogQuotaManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java index cb294610a791e1..3862757596d597 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java @@ -82,10 +82,12 @@ public BacklogQuota getBacklogQuota(TopicName topicName) { } try { - return Optional.ofNullable(pulsar.getTopicPoliciesService().getTopicPolicies(topicName)) - .map(TopicPolicies::getBackLogQuotaMap) - .map(map -> map.get(BacklogQuotaType.destination_storage.name())) - .orElseGet(() -> getBacklogQuota(topicName.getNamespace(), policyPath)); + if (pulsar.getTopicPoliciesService().cacheIsInitialized(topicName)) { + return Optional.ofNullable(pulsar.getTopicPoliciesService().getTopicPolicies(topicName)) + .map(TopicPolicies::getBackLogQuotaMap) + .map(map -> map.get(BacklogQuotaType.destination_storage.name())) + .orElseGet(() -> getBacklogQuota(topicName.getNamespace(), policyPath)); + } } catch (Exception e) { log.warn("Failed to read topic policies data, will apply the namespace backlog quota: topicName={}", topicName, e);