Skip to content

Commit beee84f

Browse files
authored
[ISSUE #9868] Fix getBrokerEpoch no response issue for empty parameters (#9869)
1 parent 15796e7 commit beee84f

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerEpochSubCommand.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Set;
2121
import org.apache.commons.cli.CommandLine;
2222
import org.apache.commons.cli.Option;
23+
import org.apache.commons.cli.OptionGroup;
2324
import org.apache.commons.cli.Options;
2425
import org.apache.rocketmq.remoting.RPCHook;
2526
import org.apache.rocketmq.remoting.protocol.EpochEntry;
@@ -43,15 +44,13 @@ public String commandDesc() {
4344

4445
@Override
4546
public Options buildCommandlineOptions(Options options) {
46-
Option opt = new Option("c", "clusterName", true, "which cluster");
47-
opt.setRequired(false);
48-
options.addOption(opt);
49-
50-
opt = new Option("b", "brokerName", true, "which broker to fetch");
51-
opt.setRequired(false);
52-
options.addOption(opt);
47+
OptionGroup group = new OptionGroup();
48+
group.addOption(new Option("c", "clusterName", true, "which cluster"));
49+
group.addOption(new Option("b", "brokerName", true, "which broker to fetch"));
50+
group.setRequired(true);
51+
options.addOptionGroup(group);
5352

54-
opt = new Option("i", "interval", true, "the interval(second) of get info");
53+
Option opt = new Option("i", "interval", true, "the interval(second) of get info");
5554
opt.setRequired(false);
5655
options.addOption(opt);
5756

@@ -68,7 +67,7 @@ public void execute(CommandLine commandLine, Options options,
6867
if (commandLine.hasOption('i')) {
6968
String interval = commandLine.getOptionValue('i');
7069
int flushSecond = 3;
71-
if (interval != null && !interval.trim().equals("")) {
70+
if (interval != null && !interval.trim().isEmpty()) {
7271
flushSecond = Integer.parseInt(interval);
7372
}
7473

0 commit comments

Comments
 (0)