merlimat commented on a change in pull request #9554:
URL: https://github.com/apache/pulsar/pull/9554#discussion_r574012085
##########
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:
```suggestion
producers.keySet().stream().findFirst().map(p ->
errorMsg.append(": " ).append(p));
```
##########
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());
+ }
+ return FutureUtil.failedFuture(new
ProducerBusyException(errorMsg.toString()));
} else {
// Normal producer getting added, we don't need a new epoch
return CompletableFuture.completedFuture(topicEpoch);
}
case Exclusive:
if (hasExclusiveProducer ||
!waitingExclusiveProducers.isEmpty()) {
- return FutureUtil.failedFuture(new ProducerFencedException(
- "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:
```suggestion
producers.keySet().stream().findFirst().map(p ->
errorMsg.append(": " ).append(p));
```
----------------------------------------------------------------
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]