From 4400f365cec329acbff4148c9fee022058a4c9c6 Mon Sep 17 00:00:00 2001 From: Fei Wang Date: Fri, 29 Apr 2022 18:53:56 +0800 Subject: [PATCH 1/2] [KYUUBI #2478][FOLLOWUP] Invoke getOpts method instead of Reflection --- .../java/org/apache/hive/beeline/KyuubiBeeLine.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java index 2eec5bbfa1d..c46cc621429 100644 --- a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java +++ b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java @@ -162,15 +162,7 @@ int initArgs(String[] args) { int code = 0; if (cl.getOptionValues('e') != null) { commands = Arrays.asList(cl.getOptionValues('e')); - try { - Field optsField = BeeLine.class.getDeclaredField("opts"); - optsField.setAccessible(true); - BeeLineOpts opts = (BeeLineOpts) optsField.get(this); - opts.setAllowMultiLineCommand(false); - } catch (Exception t) { - error(t.getMessage()); - return 1; - } + getOpts().setAllowMultiLineCommand(false); // When using -e, command is always a single line } if (!commands.isEmpty() && getOpts().getScriptFile() != null) { From f188d78b89d522926ea4da3f1ee6c7c0792848a0 Mon Sep 17 00:00:00 2001 From: Fei Wang Date: Fri, 29 Apr 2022 20:53:50 +0800 Subject: [PATCH 2/2] comment --- .../src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java index c46cc621429..9ddde00557c 100644 --- a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java +++ b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java @@ -162,7 +162,8 @@ int initArgs(String[] args) { int code = 0; if (cl.getOptionValues('e') != null) { commands = Arrays.asList(cl.getOptionValues('e')); - getOpts().setAllowMultiLineCommand(false); // When using -e, command is always a single line + // When using -e, command is always a single line, see HIVE-19018 + getOpts().setAllowMultiLineCommand(false); } if (!commands.isEmpty() && getOpts().getScriptFile() != null) {