BewareMyPower commented on code in PR #22797:
URL: https://github.com/apache/pulsar/pull/22797#discussion_r1620205897
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5360,6 +5392,17 @@ protected CompletableFuture<Void>
internalSetShadowTopic(List<String> shadowTopi
return FutureUtil.failedFuture(new
RestException(Status.PRECONDITION_FAILED,
"Cannot specify empty shadow topics, please use remove
command instead."));
}
+ try {
+ shadowTopics.forEach(shadowTopic -> {
+ if (TopicName.get(shadowTopic).isPartitioned()) {
+ throw new RestException(Status.PRECONDITION_FAILED,
+ "Couldn't set a partition of a topic as the shadow
topic.");
+ }
+ });
+ } catch (RestException e) {
+ return FutureUtil.failedFuture(e);
+ }
Review Comment:
A trivial range for loop will be more clear that it won't need to break the
`forEach` by throwing an exception first.
```java
for (var shadowTopic : shadowTopics) {
if (TopicName.get(shadowTopic).isPartitioned()) {
return CompletableFuture.failedFuture(new
RestException(Status.PRECONDITION_FAILED,
"Couldn't set a partition of a topic as the shadow
topic."));
}
}
```
--
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]