-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22950][SQL]Handle ChildFirstURLClassLoader's parent #20145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,11 +17,16 @@ | |
|
|
||
| package org.apache.spark.sql.hive | ||
|
|
||
| import java.net.URL | ||
|
|
||
| import org.apache.hadoop.hive.conf.HiveConf.ConfVars | ||
|
|
||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.sql.QueryTest | ||
| import org.apache.spark.sql.hive.test.TestHiveSingleton | ||
| import org.apache.spark.sql.test.SQLTestUtils | ||
| import org.apache.spark.util.{ChildFirstURLClassLoader, MutableURLClassLoader} | ||
|
|
||
| class HiveUtilsSuite extends QueryTest with SQLTestUtils with TestHiveSingleton { | ||
|
|
||
|
|
@@ -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) | ||
|
||
| extends MutableURLClassLoader(urls, null) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this test trying to test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just indicates that if we don't handle child first classloader's parent, we will get caught in exception. if it bothers, i can del it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove it. The below tests case would fail without your PR, that proves your patch already.