This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.11
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.11 by this push:
new d43063e Enhancement: add backgroup exec for cli -e function (#2659)
d43063e is described below
commit d43063e19a2be8e01eaf836c6ce6d77957b57ae9
Author: gwmh <[email protected]>
AuthorDate: Tue Feb 9 10:16:29 2021 +0800
Enhancement: add backgroup exec for cli -e function (#2659)
---
cli/src/main/java/org/apache/iotdb/cli/Cli.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
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 dbeae4b..58af6ec 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -108,18 +108,13 @@ public class Cli extends AbstractCli {
}
private static void serve() {
- try (ConsoleReader reader = new ConsoleReader()) {
- reader.setExpandEvents(false);
-
+ try {
host = checkRequiredArg(HOST_ARGS, HOST_NAME, commandLine, false, host);
port = checkRequiredArg(PORT_ARGS, PORT_NAME, commandLine, false, port);
username = checkRequiredArg(USERNAME_ARGS, USERNAME_NAME, commandLine,
true, null);
password = commandLine.getOptionValue(PASSWORD_ARGS);
- if (password == null) {
- password = reader.readLine("please input your password:", '\0');
- }
- if (hasExecuteSQL) {
+ if (hasExecuteSQL && password != null) {
try (IoTDBConnection connection = (IoTDBConnection) DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + host + ":" + port + "/",
username, password)) {
properties = connection.getServerProperties();
@@ -130,8 +125,13 @@ public class Cli extends AbstractCli {
println(IOTDB_CLI_PREFIX + "> can't execute sql because" +
e.getMessage());
}
}
-
- receiveCommands(reader);
+ try (ConsoleReader reader = new ConsoleReader()) {
+ reader.setExpandEvents(false);
+ if (password == null) {
+ password = reader.readLine("please input your password:", '\0');
+ }
+ receiveCommands(reader);
+ }
} catch (ArgsErrorException e) {
println(IOTDB_CLI_PREFIX + "> input params error because" +
e.getMessage());
} catch (Exception e) {