mattisonchao commented on code in PR #20613:
URL: https://github.com/apache/pulsar/pull/20613#discussion_r1241005632
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -362,13 +362,20 @@ private void
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
policyCacheInitMap.computeIfPresent(
reader.getSystemTopic().getTopicName().getNamespaceObject(), (k, v) -> true);
// replay policy message
- policiesCache.forEach(((topicName, topicPolicies) -> {
- if (listeners.get(topicName) != null) {
- for (TopicPolicyListener<TopicPolicies> listener :
listeners.get(topicName)) {
- listener.onUpdate(topicPolicies);
+ try {
+ policiesCache.forEach(((topicName, topicPolicies) -> {
+ if (listeners.get(topicName) != null) {
+ for (TopicPolicyListener<TopicPolicies> listener :
listeners.get(topicName)) {
+ listener.onUpdate(topicPolicies);
+ }
}
- }
- }));
+ }));
+ } catch (Throwable e) {
+ log.error("[{}] Failed to replay policy message.",
reader.getSystemTopic().getTopicName(), e);
+ future.completeExceptionally(e);
Review Comment:
The callback will invoke before `cleanCacheAndCloseReader`, which may cause
some inconsistent status. :)
1. Considering someone who checks the cache and reader status in the future
callback.
2. Considering `completeExceptionally` throw exception. (logically)
--
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]