Repository: hive Updated Branches: refs/heads/master 3187fb369 -> e6b511586
HIVE-13589: beeline - support prompt for password with '-u' option(Ke Jia, reviewed by Vihang Karajgaonkar and Ferdinand Xu) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e6b51158 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e6b51158 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e6b51158 Branch: refs/heads/master Commit: e6b5115868ca42f974e525d2309e747be65f5d80 Parents: 3187fb3 Author: Ferdinand Xu <[email protected]> Authored: Thu Sep 1 06:38:33 2016 +0800 Committer: Ferdinand Xu <[email protected]> Committed: Thu Sep 1 06:38:33 2016 +0800 ---------------------------------------------------------------------- .../src/java/org/apache/hive/beeline/BeeLine.java | 15 +++++++++------ .../src/java/org/apache/hive/beeline/Commands.java | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/e6b51158/beeline/src/java/org/apache/hive/beeline/BeeLine.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index ecd60f6..8e65e39 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -881,6 +881,7 @@ public class BeeLine implements Closeable { } try { + ConsoleReader reader = getConsoleReader(inputStream); if (isBeeLine) { int code = initArgs(args); if (code != 0) { @@ -905,7 +906,7 @@ public class BeeLine implements Closeable { } catch (Exception e) { // ignore } - ConsoleReader reader = getConsoleReader(inputStream); + return execute(reader, false); } finally { close(); @@ -1079,14 +1080,16 @@ public class BeeLine implements Closeable { Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { + if(consoleReader != null) { History h = consoleReader.getHistory(); if (h instanceof FileHistory) { - try { - ((FileHistory) h).flush(); - } catch (IOException e) { - error(e); - } + try { + ((FileHistory) h).flush(); + } catch (IOException e) { + error(e); + } } + } } })); http://git-wip-us.apache.org/repos/asf/hive/blob/e6b51158/beeline/src/java/org/apache/hive/beeline/Commands.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/Commands.java b/beeline/src/java/org/apache/hive/beeline/Commands.java index a25e09b..47f5022 100644 --- a/beeline/src/java/org/apache/hive/beeline/Commands.java +++ b/beeline/src/java/org/apache/hive/beeline/Commands.java @@ -1501,7 +1501,7 @@ public class Commands { username = beeLine.getConsoleReader().readLine("Enter username for " + url + ": "); } props.setProperty(JdbcConnectionParams.AUTH_USER, username); - if (password == null) { + if (password == null || password.length() == 0) { password = beeLine.getConsoleReader().readLine("Enter password for " + url + ": ", new Character('*')); }
