RobertIndie commented on code in PR #22797:
URL: https://github.com/apache/pulsar/pull/22797#discussion_r1623740384
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -450,19 +450,23 @@ protected CompletableFuture<Void>
internalCreateNonPartitionedTopicAsync(boolean
// update remote cluster
return namespaceResources().getPoliciesAsync(namespaceName)
.thenCompose(policies -> {
- if (!policies.isPresent()) {
+ if (policies.isEmpty()) {
return
CompletableFuture.completedFuture(null);
}
// Combine namespace level policies and topic
level policies.
Set<String> replicationClusters =
policies.get().replication_clusters;
TopicPolicies topicPolicies =
pulsarService.getTopicPoliciesService().getTopicPoliciesIfExists(topicName);
- if (topicPolicies != null) {
- replicationClusters = new
HashSet<>(topicPolicies.getReplicationClusters());
+ if (topicPolicies != null &&
topicPolicies.getReplicationClusters() != null) {
+ replicationClusters = new HashSet<>();
}
Review Comment:
The `topicPolicies.getReplicationClusters()` may be null and it will throw
NPE when creating the HashSet.
It can be reproduced when running the `testPartitionedShadowTopicExpansion`.
--
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]