BewareMyPower commented on code in PR #22797: URL: https://github.com/apache/pulsar/pull/22797#discussion_r1620210077
########## 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: Or the following code for FP style: ```java if (shadowTopics.stream().map(TopicName::get).anyMatch(TopicName::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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org