Skip to content

Commit fef6c9c

Browse files
author
Andrew Or
committed
Restore deprecation logic for spark.executor.userClassPathFirst
1 parent 94b4dfa commit fef6c9c

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

core/src/main/scala/org/apache/spark/executor/Executor.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ private[spark] class Executor(
9292
private val executorActor = env.actorSystem.actorOf(
9393
Props(new ExecutorActor(executorId)), "ExecutorActor")
9494

95+
// Whether to load classes in user jars before those in Spark jars
96+
private val userClassPathFirst =
97+
conf.getBoolean("spark.executor.userClassPathFirst",
98+
conf.getBoolean("spark.files.userClassPathFirst", false))
99+
95100
// Create our ClassLoader
96101
// do this after SparkEnv creation so can access the SecurityManager
97102
private val urlClassLoader = createClassLoader()
@@ -309,7 +314,7 @@ private[spark] class Executor(
309314
val urls = userClassPath.toArray ++ currentJars.keySet.map { uri =>
310315
new File(uri.split("/").last).toURI.toURL
311316
}
312-
if (conf.getBoolean("spark.executor.userClassPathFirst", false)) {
317+
if (userClassPathFirst) {
313318
new ChildFirstURLClassLoader(urls, currentLoader)
314319
} else {
315320
new MutableURLClassLoader(urls, currentLoader)
@@ -324,14 +329,13 @@ private[spark] class Executor(
324329
val classUri = conf.get("spark.repl.class.uri", null)
325330
if (classUri != null) {
326331
logInfo("Using REPL class URI: " + classUri)
327-
val userClassPathFirst: java.lang.Boolean =
328-
conf.getBoolean("spark.executor.userClassPathFirst", false)
329332
try {
333+
val _userClassPathFirst: java.lang.Boolean = userClassPathFirst
330334
val klass = Class.forName("org.apache.spark.repl.ExecutorClassLoader")
331335
.asInstanceOf[Class[_ <: ClassLoader]]
332336
val constructor = klass.getConstructor(classOf[SparkConf], classOf[String],
333337
classOf[ClassLoader], classOf[Boolean])
334-
constructor.newInstance(conf, classUri, parent, userClassPathFirst)
338+
constructor.newInstance(conf, classUri, parent, _userClassPathFirst)
335339
} catch {
336340
case _: ClassNotFoundException =>
337341
logError("Could not find org.apache.spark.repl.ExecutorClassLoader on classpath!")

core/src/test/scala/org/apache/spark/SparkConfSuite.scala

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,23 @@ class SparkConfSuite extends FunSuite with LocalSparkContext with ResetSystemPro
198198
}
199199

200200
test("deprecated config keys") {
201+
val conf = new SparkConf().set("spark.executor.userClassPathFirst", "true")
202+
assert(conf.contains("spark.executor.userClassPathFirst"))
203+
assert(!conf.contains("spark.files.userClassPathFirst"))
204+
assert(conf.get("spark.executor.userClassPathFirst") === "true")
205+
assert(conf.get("spark.files.userClassPathFirst") === "true")
206+
}
207+
208+
test("deprecated config does not override original config") {
201209
val conf = new SparkConf()
202210
.set("spark.files.userClassPathFirst", "true")
203-
.set("spark.yarn.user.classpath.first", "true")
204-
assert(conf.contains("spark.files.userClassPathFirst"))
205-
assert(conf.contains("spark.executor.userClassPathFirst"))
206-
assert(conf.contains("spark.yarn.user.classpath.first"))
207-
assert(conf.getBoolean("spark.files.userClassPathFirst", false))
208-
assert(conf.getBoolean("spark.executor.userClassPathFirst", false))
209-
assert(conf.getBoolean("spark.yarn.user.classpath.first", false))
211+
.set("spark.executor.userClassPathFirst", "false")
212+
val conf2 = new SparkConf()
213+
.set("spark.executor.userClassPathFirst", "false")
214+
.set("spark.files.userClassPathFirst", "true")
215+
// In both cases, the new config's value should be used
216+
assert(conf.get("spark.executor.userClassPathFirst") === "false")
217+
assert(conf2.get("spark.executor.userClassPathFirst") === "false")
210218
}
211219

212220
}

yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ object Client extends Logging {
955955
if (isDriver) {
956956
conf.getBoolean("spark.driver.userClassPathFirst", false)
957957
} else {
958-
conf.getBoolean("spark.executor.userClassPathFirst", false)
958+
conf.getBoolean("spark.executor.userClassPathFirst",
959+
conf.getBoolean("spark.files.userClassPathFirst", false))
959960
}
960961
}
961962

0 commit comments

Comments
 (0)