pan3793 commented on a change in pull request #1973:
URL: https://github.com/apache/incubator-kyuubi/pull/1973#discussion_r816389376
##########
File path: kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
##########
@@ -140,7 +140,54 @@ object Utils extends Logging {
dir
}
- def currentUser: String =
UserGroupInformation.getCurrentUser.getShortUserName
+ /**
+ * Get the ClassLoader which loaded Kyuubi.
+ */
+ def getKyuubiClassLoader: ClassLoader = getClass.getClassLoader
+
+ /**
+ * Get the Context ClassLoader on this thread or, if not present, the
ClassLoader that
+ * loaded Kyuubi.
+ *
+ * This should be used whenever passing a ClassLoader to Class.ForName or
finding the currently
+ * active loader when setting up ClassLoader delegation chains.
+ */
+ def getContextOrKyuubiClassLoader: ClassLoader =
+
Option(Thread.currentThread().getContextClassLoader).getOrElse(getKyuubiClassLoader)
+
+ /**
+ * Preferred alternative to Class.forName(className), as well as
+ * Class.forName(className, initialize, loader) with current thread's
ContextClassLoader.
+ */
+ def classForName[C](
+ className: String,
+ initialize: Boolean = true,
+ noKyuubiClassLoader: Boolean = false): Class[C] = {
Review comment:
Could you please change this variable to something positive?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]