You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2020/11/13 07:39:31 UTC
[iotdb] 01/01: fix maxPRC 0
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch jira-990
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5d50b3843d128d9d28a8bb6ad3608c7a245e5b1b
Author: HTHou <hh...@outlook.com>
AuthorDate: Fri Nov 13 15:38:39 2020 +0800
fix maxPRC 0
---
cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java | 9 ++++-----
cli/src/main/java/org/apache/iotdb/cli/Cli.java | 2 +-
cli/src/main/java/org/apache/iotdb/cli/WinCli.java | 8 +++++---
cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java | 2 ++
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index ffc8c39..e413f53 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -46,7 +46,6 @@ import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.iotdb.jdbc.IoTDBJDBCResultSet;
import org.apache.iotdb.service.rpc.thrift.ServerProperties;
import org.apache.iotdb.tool.ImportCsv;
-import org.apache.thrift.TException;
public abstract class AbstractCli {
@@ -306,8 +305,8 @@ public abstract class AbstractCli {
static void setMaxDisplayNumber(String maxDisplayNum) {
long tmp = Long.parseLong(maxDisplayNum.trim());
- if (tmp > Integer.MAX_VALUE || tmp < 0) {
- maxPrintRowCount = Integer.MAX_VALUE;
+ if (tmp > Integer.MAX_VALUE || tmp <= 0) {
+ throw new NumberFormatException();
} else {
maxPrintRowCount = Integer.parseInt(maxDisplayNum.trim());
}
@@ -407,7 +406,7 @@ public abstract class AbstractCli {
}
if (specialCmd.startsWith(SET_MAX_DISPLAY_NUM)) {
- setMaxDisplaNum(specialCmd, cmd);
+ setMaxDisplayNum(specialCmd, cmd);
return OperationResult.CONTINUE_OPER;
}
@@ -506,7 +505,7 @@ public abstract class AbstractCli {
println("Fetch size has set to " + values[1].trim());
}
- private static void setMaxDisplaNum(String specialCmd, String cmd) {
+ private static void setMaxDisplayNum(String specialCmd, String cmd) {
String[] values = specialCmd.split("=");
if (values.length != 2) {
println(String.format("Max display number format error, please input like %s = 10000",
diff --git a/cli/src/main/java/org/apache/iotdb/cli/Cli.java b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
index ba877ee..dbeae4b 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -101,7 +101,7 @@ public class Cli extends AbstractCli {
return false;
} catch (NumberFormatException e) {
println(
- IOTDB_CLI_PREFIX + "> error format of max print row count, it should be number");
+ IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number and greater than 0");
return false;
}
return true;
diff --git a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
index cc956d1..4cd27d7 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
@@ -99,8 +99,10 @@ public class WinCli extends AbstractCli {
}
if (commandLine.hasOption(MAX_PRINT_ROW_COUNT_ARGS)) {
maxPrintRowCount = Integer.parseInt(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
- if (maxPrintRowCount < 0) {
- maxPrintRowCount = Integer.MAX_VALUE;
+ if (maxPrintRowCount <= 0) {
+ println(
+ IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number greater than 0");
+ return false;
}
}
} catch (ParseException e) {
@@ -109,7 +111,7 @@ public class WinCli extends AbstractCli {
return false;
} catch (NumberFormatException e) {
println(
- IOTDB_CLI_PREFIX + "> error format of max print row count, it should be number");
+ IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number");
return false;
}
return true;
diff --git a/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java b/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
index d6bfb61..d62a419 100644
--- a/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
+++ b/cli/src/test/java/org/apache/iotdb/cli/AbstractCliIT.java
@@ -214,5 +214,7 @@ public class AbstractCliIT {
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("-10");
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
+ AbstractCli.setMaxDisplayNumber("0");
+ assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
}
}