yuruguo commented on issue #11775:
URL: https://github.com/apache/pulsar/issues/11775#issuecomment-906173415
I think the reason for this problem is related to the following:
Whether it is exclusive or non-exclusive mode, we need to judge whether
`--subscriptions size` and `--num-subscriptions` are equal. But why the code
judges `--subscriptions size` and `--num-consumers` and limits to
non-exclusive mode, as follows:
> // class: org.apache.pulsar.testclient.PerformanceConsumer, line:
226-241
if (arguments.subscriptionType != SubscriptionType.Exclusive &&
arguments.subscriptions != null &&
arguments.subscriptions.size() != arguments.numConsumers) {
// keep compatibility with the previous version
if (arguments.subscriptions.size() == 1) {
List<String> defaultSubscriptions = Lists.newArrayList();
for (int i = 0; i < arguments.numSubscriptions; i++) {
defaultSubscriptions.add(String.format("%s-%d",
arguments.subscriberName, i));
}
arguments.subscriptions = defaultSubscriptions;
} else {
System.out.println("The size of subscriptions list should be
equal to --num-consumers when subscriptionType isn't Exclusive");
jc.usage();
PerfClientUtils.exit(-1);
}
}
And this logic causes the IndexOutOfBoundsException behind, as follows:
> // class: org.apache.pulsar.testclient.PerformanceConsumer,
line: 368-374
for (int j = 0; j < arguments.numSubscriptions; j++) {
String subscriberName = arguments.subscriptions.get(j);
for (int k = 0; k < arguments.numConsumers; k++) {
futures.add(consumerBuilder.clone().topic(topicName.toString()).subscriptionName(subscriberName)
.subscribeAsync());
}
}
Therefore, we only need to modify the judgment logic of `--subscriptions
size` and `--num-subscriptions` to solve this problem, as follows:

@codelipenghui @eolivelli
--
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]