Skip to content

Commit

Permalink
[IOTDB-1659] Fix Windows CLI cannot set maxPRC less than or equal to 0 (
Browse files Browse the repository at this point in the history
  • Loading branch information
HTHou committed Sep 9, 2021
1 parent d5ebc3c commit 601df56
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/src/main/java/org/apache/iotdb/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static boolean parseCommandLine(Options options, String[] newArgs, HelpF
} catch (NumberFormatException e) {
println(
IOTDB_CLI_PREFIX
+ "> error format of max print row count, it should be a number and greater than 0");
+ "> error format of max print row count, it should be an integer number");
return false;
}
return true;
Expand Down
12 changes: 4 additions & 8 deletions cli/src/main/java/org/apache/iotdb/cli/WinCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,16 @@ private static boolean parseCommandLine(Options options, String[] newArgs, HelpF
timeFormat = RpcUtils.setTimeFormat("long");
}
if (commandLine.hasOption(MAX_PRINT_ROW_COUNT_ARGS)) {
maxPrintRowCount = Integer.parseInt(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
if (maxPrintRowCount <= 0) {
println(
IOTDB_CLI_PREFIX
+ "> error format of max print row count, it should be a number greater than 0");
return false;
}
setMaxDisplayNumber(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
}
} catch (ParseException e) {
println("Require more params input, please check the following hint.");
hf.printHelp(IOTDB_CLI_PREFIX, options, true);
return false;
} catch (NumberFormatException e) {
println(IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number");
println(
IOTDB_CLI_PREFIX
+ "> error format of max print row count, it should be an integer number");
return false;
}
return true;
Expand Down
27 changes: 27 additions & 0 deletions cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ protected void testOnWindows() throws IOException {
"cmd.exe",
"/c",
dir + File.separator + "sbin" + File.separator + "start-cli.bat",
"-maxPRC",
"0",
"-e",
"\"flush\"");
testOutput(builder2, output2);

final String[] output3 = {
"IoTDB> error format of max print row count, it should be an integer number"
};
ProcessBuilder builder3 =
new ProcessBuilder(
"cmd.exe",
"/c",
dir + File.separator + "sbin" + File.separator + "start-cli.bat",
"-maxPRC",
"-1111111111111111111111111111");
testOutput(builder3, output3);
}

@Override
Expand Down Expand Up @@ -105,8 +119,21 @@ protected void testOnUnix() throws IOException {
new ProcessBuilder(
"sh",
dir + File.separator + "sbin" + File.separator + "start-cli.sh",
"-maxPRC",
"0",
"-e",
"\"flush\"");
testOutput(builder2, output2);

final String[] output3 = {
"IoTDB> error format of max print row count, it should be an integer number"
};
ProcessBuilder builder3 =
new ProcessBuilder(
"sh",
dir + File.separator + "sbin" + File.separator + "start-cli.sh",
"-maxPRC",
"-1111111111111111111111111111");
testOutput(builder3, output3);
}
}

0 comments on commit 601df56

Please sign in to comment.