diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiException.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiException.scala index e1f65fb7a..d167ed8f2 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiException.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiException.scala @@ -20,5 +20,4 @@ package org.apache.kyuubi class KyuubiException(message: String, cause: Throwable) extends Exception(message, cause) { def this(message: String) = this(message, null) - def this(cause: Throwable) = this(cause.getMessage, cause) } diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/Service.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/Service.scala index d0c31066e..683969414 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/Service.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/Service.scala @@ -24,7 +24,7 @@ trait Service { /** * Initialize the service. * - * The transition must be from [[LATENT]]to [[INITIALIZED]] unless the + * The transition must be from [[LATENT]] to [[INITIALIZED]] unless the * operation failed and an exception was raised. * * @param conf the configuration of the service diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiSQLExceptionSuite.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiSQLExceptionSuite.scala index cc91b1f61..658a55fe9 100644 --- a/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiSQLExceptionSuite.scala +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiSQLExceptionSuite.scala @@ -26,7 +26,7 @@ class KyuubiSQLExceptionSuite extends KyuubiFunSuite { val msg1 = "this is just a dummy msg 1" val msg2 = "this is just a dummy msg 2" - val e0 = new RuntimeException(msg0) + val e0 = new KyuubiException(msg0) val e1 = new KyuubiException(msg1, e0) val e2 = new KyuubiSQLException(msg2, e1) assert(e2.toTStatus === KyuubiSQLException.toTStatus(e2)) diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/cli/HandleIdentifierSuite.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/cli/HandleIdentifierSuite.scala index 1507a710d..beaccae4d 100644 --- a/kyuubi-common/src/test/scala/org/apache/kyuubi/cli/HandleIdentifierSuite.scala +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/cli/HandleIdentifierSuite.scala @@ -37,5 +37,8 @@ class HandleIdentifierSuite extends KyuubiFunSuite { val id4 = HandleIdentifier() assert(id4 !== id1) assert(id4 !== new Integer(1)) + + val id5 = HandleIdentifier(id1.publicId, id1.publicId) + assert(id1 !== id5, "no matched secret id") } } diff --git a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala index 04bd8b613..7226ccd34 100644 --- a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala +++ b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala @@ -98,7 +98,7 @@ class ServiceDiscovery private ( .forPath(s"/$namespace") } catch { case _: NodeExistsException => // do nothing - case e: KeeperException => throw new KyuubiException(e) + case e: KeeperException => throw new KyuubiException(s"Failed to create namespace '/$namespace'", e) } super.initialize(conf) } diff --git a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/cli/HandleIdentifierSuite.scala b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/cli/HandleIdentifierSuite.scala deleted file mode 100644 index 0cd733b7d..000000000 --- a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/cli/HandleIdentifierSuite.scala +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 yaooqinn.kyuubi.cli - -import java.nio.ByteBuffer -import java.util.UUID - -import org.apache.hive.service.cli.thrift.THandleIdentifier -import org.apache.spark.SparkFunSuite - -class HandleIdentifierSuite extends SparkFunSuite { - - test("handle identifier instantiating and equality") { - // default constructor - val pid = UUID.randomUUID() - val sid = UUID.randomUUID() - val handleId1 = new HandleIdentifier(pid, sid) - assert(pid === handleId1.getPublicId) - assert(sid === handleId1.getSecretId) - assert(handleId1.toTHandleIdentifier.bufferForGuid() !== null) - assert(handleId1.toTHandleIdentifier.bufferForSecret() !== null) - assert(handleId1.toString === pid.toString) - - // constructor without any parameter - val handleId2 = new HandleIdentifier() - assert(pid !== handleId2.getPublicId) - assert(sid !== handleId2.getSecretId) - assert(handleId1 !== handleId2) - assert(handleId1.toTHandleIdentifier !== handleId2.toTHandleIdentifier) - - // constructor with THandleIdentifier - val handleId3 = new HandleIdentifier(handleId1.toTHandleIdentifier) - assert(handleId1 === handleId3) - - val tHandleId = new THandleIdentifier(ByteBuffer.allocate(16), ByteBuffer.allocate(16)) - val handleId4 = new HandleIdentifier(tHandleId) - assert(handleId1 !== handleId4) - - } -}