Skip to content

Commit b1f9e35

Browse files
authored
[improve][cli] pulsar-perf: check for invalid CLI options (#18889)
1 parent 3011946 commit b1f9e35

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ public static void main(String[] args) throws Exception {
223223
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
224224
}
225225

226+
for (String arg : arguments.topic) {
227+
if (arg.startsWith("-")) {
228+
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
229+
+ "please use a fully qualified topic name\n", arg, arg);
230+
jc.usage();
231+
PerfClientUtils.exit(-1);
232+
}
233+
}
234+
226235
if (arguments.topic != null && arguments.topic.size() != arguments.numTopics) {
227236
// keep compatibility with the previous version
228237
if (arguments.topic.size() == 1) {

pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ public static void main(String[] args) throws Exception {
292292
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
293293
}
294294

295+
for (String arg : arguments.topics) {
296+
if (arg.startsWith("-")) {
297+
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
298+
+ "please use a fully qualified topic name\n", arg, arg);
299+
jc.usage();
300+
PerfClientUtils.exit(-1);
301+
}
302+
}
303+
295304
if (arguments.topics != null && arguments.topics.size() != arguments.numTopics) {
296305
// keep compatibility with the previous version
297306
if (arguments.topics.size() == 1) {

pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ public static void main(String[] args) throws Exception {
122122
PerfClientUtils.exit(-1);
123123
}
124124

125+
for (String arg : arguments.topic) {
126+
if (arg.startsWith("-")) {
127+
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
128+
+ "please use a fully qualified topic name\n", arg, arg);
129+
jc.usage();
130+
PerfClientUtils.exit(-1);
131+
}
132+
}
133+
125134
if (arguments.topic != null && arguments.topic.size() != arguments.numTopics) {
126135
// keep compatibility with the previous version
127136
if (arguments.topic.size() == 1) {

0 commit comments

Comments
 (0)