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:
[email protected]


Reply via email to