Github user yaooqinn commented on a diff in the pull request:
https://github.com/apache/spark/pull/20145#discussion_r159585110
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveUtilsSuite.scala ---
@@ -42,4 +47,29 @@ class HiveUtilsSuite extends QueryTest with SQLTestUtils
with TestHiveSingleton
assert(hiveConf("foo") === "bar")
}
}
+
+ test("ChildFirstURLClassLoader's parent is null") {
+ val conf = new SparkConf
+ val contextClassLoader = Thread.currentThread().getContextClassLoader
+ val loader = new FakeChildFirstURLClassLoader(Array(),
contextClassLoader)
+ Thread.currentThread().setContextClassLoader(loader)
+ intercept[IllegalArgumentException](
+ HiveUtils.newClientForMetadata(conf,
SparkHadoopUtil.newConfiguration(conf)))
+ Thread.currentThread().setContextClassLoader(contextClassLoader)
+ }
+
+ test("ChildFirstURLClassLoader's parent is null, get spark classloader
instead") {
+ val conf = new SparkConf
+ val contextClassLoader = Thread.currentThread().getContextClassLoader
+ val loader = new ChildFirstURLClassLoader(Array(), contextClassLoader)
+ Thread.currentThread().setContextClassLoader(loader)
+ HiveUtils.newClientForMetadata(conf,
SparkHadoopUtil.newConfiguration(conf))
+ Thread.currentThread().setContextClassLoader(contextClassLoader)
+ }
}
+
+/**
+ * A Fake [[ChildFirstURLClassLoader]] used for test
+ */
+private[spark] class FakeChildFirstURLClassLoader(urls: Array[URL],
parent: ClassLoader)
--- End diff --
inheritation maketh case match
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]