Repository: hive
Updated Branches:
  refs/heads/master c369a5d0d -> 1e086f269


HIVE-16693: beeline "source" command freezes if you have a comment in it? 
(Ferdinand Xu, reviewed by Carter Shanklin and Xuefu Zhang)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1e086f26
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1e086f26
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1e086f26

Branch: refs/heads/master
Commit: 1e086f2691fe58e23a43b92f6851aa824ac8d440
Parents: c369a5d
Author: Ferdinand Xu <cheng.a...@intel.com>
Authored: Mon May 22 13:40:06 2017 +0800
Committer: Ferdinand Xu <cheng.a...@intel.com>
Committed: Mon May 22 13:40:06 2017 +0800

----------------------------------------------------------------------
 beeline/src/java/org/apache/hive/beeline/Commands.java      | 6 ++----
 .../src/test/org/apache/hive/beeline/cli/TestHiveCli.java   | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/1e086f26/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 bcbc574..3b2d72e 100644
--- a/beeline/src/java/org/apache/hive/beeline/Commands.java
+++ b/beeline/src/java/org/apache/hive/beeline/Commands.java
@@ -889,9 +889,8 @@ public class Commands {
     BufferedReader reader = null;
     try {
       reader = new BufferedReader(new FileReader(sourceFile));
-      String extra = reader.readLine();
-      String lines = null;
-      while (extra != null) {
+      String lines = null, extra;
+      while ((extra = reader.readLine()) != null) {
         if (beeLine.isComment(extra)) {
           continue;
         }
@@ -900,7 +899,6 @@ public class Commands {
         } else {
           lines += "\n" + extra;
         }
-        extra = reader.readLine();
       }
       String[] cmds = lines.split(beeLine.getOpts().getDelimiter());
       for (String c : cmds) {

http://git-wip-us.apache.org/repos/asf/hive/blob/1e086f26/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java
----------------------------------------------------------------------
diff --git a/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java 
b/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java
index 8eaa683..28b0cf9 100644
--- a/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java
+++ b/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java
@@ -47,6 +47,7 @@ public class TestHiveCli {
   private final static String SOURCE_CONTEXT3 =
       "create table if not exists test.testSrcTbl3(sc3 string);";
   private final static String SOURCE_CONTEXT4 = "show tables;!ls;show 
tables;\nquit;";
+  private final static String SOURCE_CONTEXT5 = "-- test;\n;show 
tables;\nquit;";
   final static String CMD =
       "create database if not exists test;\ncreate table if not exists 
test.testTbl(a string, b "
           + "string);\n";
@@ -165,6 +166,14 @@ public class TestHiveCli {
   }
 
   @Test
+  public void testSourceCmd4() {
+    File f = generateTmpFile(SOURCE_CONTEXT5);
+    verifyCMD("source " + f.getPath() + ";", "testtbl", os,
+      new String[] { "--database", "test" }, ERRNO_OK, true);
+    f.delete();
+  }
+
+  @Test
   public void testSqlFromCmd() {
     verifyCMD(null, "", os, new String[] { "-e", "show databases;" }, 
ERRNO_OK, true);
   }

Reply via email to