Skip to content

Commit

Permalink
[fix][broker] Fix uncompleted future when get the topic policies of a…
Browse files Browse the repository at this point in the history
… deleted topic (apache#18824)

### Motivation
Fix the uncompleted future when getting the topic policies of a deleted topic. 
https://github.com/apache/pulsar/blob/30b52a1ac11b4be485258140a167b5e635586a36/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java#L513-L535
### Modification
`future.complete(null);` when `msg.getValue() == null`.
  • Loading branch information
liangyepianzhou authored and Demogorgon314 committed Dec 22, 2022
1 parent 129cf12 commit 5223203
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ private void fetchTopicPoliciesAsyncAndCloseReader(SystemTopicClient.Reader<Puls
} else {
fetchTopicPoliciesAsyncAndCloseReader(reader, topicName, policies, future);
}
} else {
future.complete(null);
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3092,4 +3092,21 @@ public void testShadowTopics() throws Exception {
Awaitility.await().untilAsserted(() -> assertNull(admin.topics().getShadowTopics(sourceTopic)));
}

@Test
public void testGetTopicPoliciesWhenDeleteTopicPolicy() throws Exception {
admin.topics().createNonPartitionedTopic(persistenceTopic);
admin.topicPolicies().setMaxConsumers(persistenceTopic, 5);

Integer maxConsumerPerTopic = pulsar
.getTopicPoliciesService()
.getTopicPoliciesBypassCacheAsync(TopicName.get(persistenceTopic)).get()
.getMaxConsumerPerTopic();

assertEquals(maxConsumerPerTopic, 5);
admin.topics().delete(persistenceTopic, true);
TopicPolicies topicPolicies =pulsar.getTopicPoliciesService()
.getTopicPoliciesBypassCacheAsync(TopicName.get(persistenceTopic)).get(5, TimeUnit.SECONDS);
assertNull(topicPolicies);
}

}

0 comments on commit 5223203

Please sign in to comment.