Skip to content
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

[SPARK-22950][SQL]Handle ChildFirstURLClassLoader's parent #20145

Closed
wants to merge 4 commits into from
Closed

[SPARK-22950][SQL]Handle ChildFirstURLClassLoader's parent #20145

wants to merge 4 commits into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Jan 4, 2018

What changes were proposed in this pull request?

ChildFirstClassLoader's parent is set to null, so we can't get jars from its parent. This will cause ClassNotFoundException during HiveClient initialization with builtin hive jars, where we may should use spark context loader instead.

How was this patch tested?

add new ut
cc @cloud-fan @gatorsmile

@yaooqinn yaooqinn changed the title [SPARK-22950]Handle ChildFirstURLClassLoader's parent [SPARK-22950][SQL]Handle ChildFirstURLClassLoader's parent Jan 4, 2018
@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85653 has finished for PR 20145 at commit 7cb0c44.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85654 has finished for PR 20145 at commit bb27e17.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Thread.currentThread().setContextClassLoader(loader)
intercept[IllegalArgumentException](
HiveUtils.newClientForMetadata(conf, SparkHadoopUtil.newConfiguration(conf)))
Thread.currentThread().setContextClassLoader(contextClassLoader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use try .. finally to make sure we always set back the context class loader

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

val loader = new ChildFirstURLClassLoader(Array(), contextClassLoader)
Thread.currentThread().setContextClassLoader(loader)
HiveUtils.newClientForMetadata(conf, SparkHadoopUtil.newConfiguration(conf))
Thread.currentThread().setContextClassLoader(contextClassLoader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

/**
* A Fake [[ChildFirstURLClassLoader]] used for test
*/
private[spark] class FakeChildFirstURLClassLoader(urls: Array[URL], parent: ClassLoader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a ChildFirstURLClassLoader, shall we make it extend ChildFirstURLClassLoader?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inheritation maketh case match

@@ -42,4 +47,41 @@ class HiveUtilsSuite extends QueryTest with SQLTestUtils with TestHiveSingleton
assert(hiveConf("foo") === "bar")
}
}

test("ChildFirstURLClassLoader's parent is null") {
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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.

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85666 has finished for PR 20145 at commit fea2490.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85663 has finished for PR 20145 at commit e1a9f2e.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yaooqinn
Copy link
Member Author

yaooqinn commented Jan 4, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85670 has finished for PR 20145 at commit fea2490.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master/2.3!

asfgit pushed a commit that referenced this pull request Jan 4, 2018
## What changes were proposed in this pull request?

ChildFirstClassLoader's parent is set to null, so we can't get jars from its parent. This will cause ClassNotFoundException during HiveClient initialization with builtin hive jars, where we may should use spark context loader instead.

## How was this patch tested?

add new ut
cc cloud-fan gatorsmile

Author: Kent Yao <yaooqinn@hotmail.com>

Closes #20145 from yaooqinn/SPARK-22950.

(cherry picked from commit 9fa703e)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@asfgit asfgit closed this in 9fa703e Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants