Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9170#discussion_r42543260
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/IsolatedClientLoader.scala
 ---
    @@ -148,39 +148,46 @@ private[hive] class IsolatedClientLoader(
       protected def classToPath(name: String): String =
         name.replaceAll("\\.", "/") + ".class"
     
    -  /** The classloader that is used to load an isolated version of Hive. */
    -  private[hive] var classLoader: ClassLoader = if (isolationOn) {
    -    new URLClassLoader(allJars, rootClassLoader) {
    -      override def loadClass(name: String, resolve: Boolean): Class[_] = {
    -        val loaded = findLoadedClass(name)
    -        if (loaded == null) doLoadClass(name, resolve) else loaded
    -      }
    -      def doLoadClass(name: String, resolve: Boolean): Class[_] = {
    -        val classFileName = name.replaceAll("\\.", "/") + ".class"
    -        if (isBarrierClass(name)) {
    -          // For barrier classes, we construct a new copy of the class.
    -          val bytes = 
IOUtils.toByteArray(baseClassLoader.getResourceAsStream(classFileName))
    -          logDebug(s"custom defining: $name - 
${util.Arrays.hashCode(bytes)}")
    -          defineClass(name, bytes, 0, bytes.length)
    -        } else if (!isSharedClass(name)) {
    -          logDebug(s"hive class: $name - 
${getResource(classToPath(name))}")
    -          super.loadClass(name, resolve)
    -        } else {
    -          // For shared classes, we delegate to baseClassLoader.
    -          logDebug(s"shared class: $name")
    -          baseClassLoader.loadClass(name)
    +  /**
    +   * The classloader that is used to load an isolated version of Hive.
    +   * This classloader is a special URLClassLoader that exposes the addURL 
method.
    +   * So, when we add jar, we can add this new jar directly through the 
addURL method
    +   * instead of stacking a new URLClassLoader on top of it.
    +   */
    +  private[hive] val classLoader: MutableURLClassLoader = {
    +    val isolatedClassLoader =
    +      if (isolationOn) {
    +        new URLClassLoader(allJars, rootClassLoader) {
    +          override def loadClass(name: String, resolve: Boolean): Class[_] 
= {
    +            val loaded = findLoadedClass(name)
    +            if (loaded == null) doLoadClass(name, resolve) else loaded
    +          }
    +          def doLoadClass(name: String, resolve: Boolean): Class[_] = {
    +            val classFileName = name.replaceAll("\\.", "/") + ".class"
    +            if (isBarrierClass(name)) {
    +              // For barrier classes, we construct a new copy of the class.
    +              val bytes = 
IOUtils.toByteArray(baseClassLoader.getResourceAsStream(classFileName))
    +              logDebug(s"custom defining: $name - 
${util.Arrays.hashCode(bytes)}")
    +              defineClass(name, bytes, 0, bytes.length)
    +            } else if (!isSharedClass(name)) {
    +              logDebug(s"hive class: $name - 
${getResource(classToPath(name))}")
    +              super.loadClass(name, resolve)
    +            } else {
    +              // For shared classes, we delegate to baseClassLoader.
    +              logDebug(s"shared class: $name")
    +              baseClassLoader.loadClass(name)
    +            }
    +          }
             }
    +      } else {
    +        baseClassLoader
           }
    -    }
    -  } else {
    -    baseClassLoader
    +    new MutableURLClassLoader(Array.empty, isolatedClassLoader)
    --- End diff --
    
    One hacky way to workaround the problem is that we have a no-op `close` 
method for this classloader. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to