srowen commented on a change in pull request #24239: [SPARK-27121][REPL] 
Resolve Scala compiler failure for Java 9+ in REPL
URL: https://github.com/apache/spark/pull/24239#discussion_r270271416
 
 

 ##########
 File path: repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
 ##########
 @@ -34,33 +33,33 @@ class ReplSuite extends SparkFunSuite {
   def runInterpreter(master: String, input: String): String = {
     val CONF_EXECUTOR_CLASSPATH = "spark.executor.extraClassPath"
 
-    val in = new BufferedReader(new StringReader(input + "\n"))
-    val out = new StringWriter()
+
     val cl = getClass.getClassLoader
-    var paths = new ArrayBuffer[String]
-    if (cl.isInstanceOf[URLClassLoader]) {
-      val urlLoader = cl.asInstanceOf[URLClassLoader]
-      for (url <- urlLoader.getURLs) {
-        if (url.getProtocol == "file") {
-          paths += url.getFile
-        }
-      }
-    }
-    val classpath = paths.map(new 
File(_).getAbsolutePath).mkString(File.pathSeparator)
 
     val oldExecutorClasspath = System.getProperty(CONF_EXECUTOR_CLASSPATH)
-    System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)
+    if (oldExecutorClasspath == null) {
+      System.clearProperty(CONF_EXECUTOR_CLASSPATH)
+    } else {
+      System.setProperty(CONF_EXECUTOR_CLASSPATH, oldExecutorClasspath)
+    }
+
+    val classpath = cl match {
+      case urlLoader: URLClassLoader =>
+        val paths = urlLoader.getURLs.filter(_.getProtocol == 
"file").map(_.getFile)
+        val classpath = paths.map(new 
File(_).getAbsolutePath).mkString(File.pathSeparator)
+        System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)
+        classpath
+      case _ => System.getProperty("java.class.path")
 
 Review comment:
   @squito this is your suggestion. I wonder why we don't just use this in all 
cases, Java 11 or no?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to