This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new c4ec5e0cbc2 [cleanup][broker] Using `getTopicPoliciesIfExists` to
avoid catching the exception (#19368)
c4ec5e0cbc2 is described below
commit c4ec5e0cbc249f96f49a98f246ed9648fb48dcfd
Author: Qiang Zhao <[email protected]>
AuthorDate: Wed Feb 1 09:37:56 2023 +0800
[cleanup][broker] Using `getTopicPoliciesIfExists` to avoid catching the
exception (#19368)
---
.../pulsar/broker/service/BrokerService.java | 23 ++++++++--------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 618cc089560..d88f040f11b 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -1676,15 +1676,12 @@ public class BrokerService implements Closeable {
if (pulsar.getConfig().isTopicLevelPoliciesEnabled()
&&
!NamespaceService.isSystemServiceNamespace(namespace.toString())) {
- try {
- TopicPolicies topicPolicies =
pulsar.getTopicPoliciesService().getTopicPolicies(topicName);
- if (topicPolicies != null) {
- persistencePolicies =
topicPolicies.getPersistence();
- retentionPolicies =
topicPolicies.getRetentionPolicies();
- topicLevelOffloadPolicies =
topicPolicies.getOffloadPolicies();
- }
- } catch
(BrokerServiceException.TopicPoliciesCacheNotInitException e) {
- log.debug("Topic {} policies have not been
initialized yet.", topicName);
+ final TopicPolicies topicPolicies =
pulsar.getTopicPoliciesService()
+ .getTopicPoliciesIfExists(topicName);
+ if (topicPolicies != null) {
+ persistencePolicies =
topicPolicies.getPersistence();
+ retentionPolicies =
topicPolicies.getRetentionPolicies();
+ topicLevelOffloadPolicies =
topicPolicies.getOffloadPolicies();
}
}
@@ -3299,12 +3296,8 @@ public class BrokerService implements Closeable {
if (!pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
return Optional.empty();
}
- try {
- return
Optional.ofNullable(pulsar.getTopicPoliciesService().getTopicPolicies(topicName));
- } catch (BrokerServiceException.TopicPoliciesCacheNotInitException e) {
- log.debug("Topic {} policies have not been initialized yet.",
topicName.getPartitionedTopicName());
- return Optional.empty();
- }
+ return Optional.ofNullable(pulsar.getTopicPoliciesService()
+ .getTopicPoliciesIfExists(topicName));
}
public CompletableFuture<Void> deleteTopicPolicies(TopicName topicName) {