RobertIndie commented on a change in pull request #13355:
URL: https://github.com/apache/pulsar/pull/13355#discussion_r802599438
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1245,9 +1247,41 @@ protected void handleProducer(final CommandProducer
cmdProducer) {
schemaVersionFuture.thenAccept(schemaVersion -> {
topic.checkIfTransactionBufferRecoverCompletely(isTxnEnabled).thenAccept(future
-> {
- buildProducerAndAddTopic(topic, producerId,
producerName, requestId, isEncrypted,
+ CompletableFuture<Subscription> initSubFuture =
new CompletableFuture<>();
+ if (!Strings.isNullOrEmpty(initialSubscriptionName)
+ &&
!topic.getSubscriptions().containsKey(initialSubscriptionName)
+ && topic.isPersistent()) {
+ initSubFuture = isTopicOperationAllowed(
+ topicName, TopicOperation.SUBSCRIBE
+ ).thenCompose(canSubscribe -> {
+ if (!canSubscribe) {
+ return FutureUtil.failedFuture(
+ new
BrokerServiceException.ProducerInitSubAuthorizationException(
+ "Client is not
authorized to subscribe."));
+ }
+ return
topic.createSubscription(initialSubscriptionName, InitialPosition.Earliest,
+ false);
+ });
+ } else {
+ initSubFuture.complete(null);
+ }
Review comment:
Thanks. I fixed it.
--
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]