Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/22192#discussion_r216106909
--- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
@@ -240,6 +240,16 @@ private[spark] object Utils extends Logging {
// scalastyle:on classforname
}
+ /**
+ * Run a segment of code using a different context class loader in the
current thread
+ */
+ def withContextClassLoader(ctxClassLoader: ClassLoader)(fn: => Unit):
Unit = {
+ val oldClassLoader = getContextOrSparkClassLoader
+ Thread.currentThread().setContextClassLoader(ctxClassLoader)
+ fn
+ Thread.currentThread().setContextClassLoader(oldClassLoader)
--- End diff --
This has to be in a `finally`.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]