[ISSUE #9868] Fix getBrokerEpoch no response issue for empty parameters (#9869)

This commit is contained in:
yx9o
2025-12-12 16:26:48 +08:00
committed by GitHub
parent 15796e73d3
commit beee84fa44
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.protocol.EpochEntry;
@@ -43,15 +44,13 @@ public class GetBrokerEpochSubCommand implements SubCommand {
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("c", "clusterName", true, "which cluster");
opt.setRequired(false);
options.addOption(opt);
OptionGroup group = new OptionGroup();
group.addOption(new Option("c", "clusterName", true, "which cluster"));
group.addOption(new Option("b", "brokerName", true, "which broker to fetch"));
group.setRequired(true);
options.addOptionGroup(group);
opt = new Option("b", "brokerName", true, "which broker to fetch");
opt.setRequired(false);
options.addOption(opt);
opt = new Option("i", "interval", true, "the interval(second) of get info");
Option opt = new Option("i", "interval", true, "the interval(second) of get info");
opt.setRequired(false);
options.addOption(opt);
@@ -68,7 +67,7 @@ public class GetBrokerEpochSubCommand implements SubCommand {
if (commandLine.hasOption('i')) {
String interval = commandLine.getOptionValue('i');
int flushSecond = 3;
if (interval != null && !interval.trim().equals("")) {
if (interval != null && !interval.trim().isEmpty()) {
flushSecond = Integer.parseInt(interval);
}