You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/02/10 17:48:09 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #9554: Fix uncaught exception in exclusive producer creation

merlimat commented on a change in pull request #9554:
URL: https://github.com/apache/pulsar/pull/9554#discussion_r573942728



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
##########
@@ -382,17 +382,25 @@ public String getReplicatorPrefix() {
             switch (producer.getAccessMode()) {
             case Shared:
                 if (hasExclusiveProducer || !waitingExclusiveProducers.isEmpty()) {
-                    return FutureUtil.failedFuture(new ProducerBusyException(
-                            "Topic has an existing exclusive producer: " + producers.keys().nextElement()));
+                    StringBuilder errorMsg = new StringBuilder();
+                    errorMsg.append("Topic has an existing exclusive producer");
+                    if (producers.keys().hasMoreElements()) {
+                        errorMsg.append(": " + producers.keys().nextElement());

Review comment:
       I'm not sure this avoids the race altogether since there's no atomicity between checking `hasMoreElements()` and `nextElement()`. I think we could get an iterator and use that to check, since it will be guaranteed to be consistent.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org