From f3bd137b4657e43053dd11c35b9a05070bb08c93 Mon Sep 17 00:00:00 2001 From: jiaoqingbo <1178404354@qq.com> Date: Sat, 9 Jul 2022 19:43:04 +0800 Subject: [PATCH] [KYUUBI #2478][FOLLOWUP] Fix bin/beeline without -u exits unexpectedly ### _Why are the changes needed?_ fix #3030 ### _How was this patch tested?_ - [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [x] Add screenshots for manual tests if appropriate ![image](https://user-images.githubusercontent.com/14961757/177953720-029882e5-2454-4091-aa75-d008e15ee1a0.png) - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #3031 from jiaoqingbo/kyuubi-3030. Closes #2478 58ba0118 [jiaoqingbo] change junit location a4130dad [jiaoqingbo] add license 9ff13665 [jiaoqingbo] [KYUUBI #3030] fix bin/beeline without -u exits unexpectedly Authored-by: jiaoqingbo <1178404354@qq.com> Signed-off-by: Fei Wang --- kyuubi-hive-beeline/pom.xml | 6 ++++ .../apache/hive/beeline/KyuubiBeeLine.java | 4 +-- .../hive/beeline/KyuubiBeeLineTest.java | 32 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java diff --git a/kyuubi-hive-beeline/pom.xml b/kyuubi-hive-beeline/pom.xml index d5affdfdcc4..728b7691375 100644 --- a/kyuubi-hive-beeline/pom.xml +++ b/kyuubi-hive-beeline/pom.xml @@ -132,6 +132,12 @@ + + + junit + junit + test + 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..8ec04d36941 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 @@ -149,9 +149,9 @@ int initArgs(String[] args) { if (!connSuccessful && !exit) { try { Method defaultBeelineConnectMethod = - BeeLine.class.getDeclaredMethod("defaultBeelineConnect"); + BeeLine.class.getDeclaredMethod("defaultBeelineConnect", CommandLine.class); defaultBeelineConnectMethod.setAccessible(true); - connSuccessful = (boolean) defaultBeelineConnectMethod.invoke(this); + connSuccessful = (boolean) defaultBeelineConnectMethod.invoke(this, cl); } catch (Exception t) { error(t.getMessage()); diff --git a/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java new file mode 100644 index 00000000000..b144c95c61f --- /dev/null +++ b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hive.beeline; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class KyuubiBeeLineTest { + @Test + public void testKyuubiBeelineWithoutArgs() { + KyuubiBeeLine kyuubiBeeLine = new KyuubiBeeLine(); + int result = kyuubiBeeLine.initArgs(new String[0]); + assertEquals(0, result); + } +}