zsxwing commented on a change in pull request #24683: [SPARK-20547][REPL]Throw 
RemoteClassLoadedError for transient errors in ExecutorClassLoader
URL: https://github.com/apache/spark/pull/24683#discussion_r287605880
 
 

 ##########
 File path: repl/src/main/scala/org/apache/spark/repl/ExecutorClassLoader.scala
 ##########
 @@ -115,23 +127,31 @@ class ExecutorClassLoader(
     }
   }
 
+  // See 
org.apache.spark.network.server.TransportRequestHandler.processStreamRequest.
+  private val STREAM_NOT_FOUND_REGEX = s"Stream '.*' was not found.".r.pattern
+
   private def getClassFileInputStreamFromSparkRPC(path: String): InputStream = 
{
-    val channel = env.rpcEnv.openChannel(s"$classUri/$path")
+    val channel = env.rpcEnv.openChannel(s"$classUri/${urlEncode(path)}")
     new FilterInputStream(Channels.newInputStream(channel)) {
 
       override def read(): Int = toClassNotFound(super.read())
 
-      override def read(b: Array[Byte]): Int = toClassNotFound(super.read(b))
-
       override def read(b: Array[Byte], offset: Int, len: Int) =
         toClassNotFound(super.read(b, offset, len))
 
       private def toClassNotFound(fn: => Int): Int = {
         try {
           fn
         } catch {
-          case e: Exception =>
+          case e: RuntimeException if e.getMessage != null
+            && STREAM_NOT_FOUND_REGEX.matcher(e.getMessage).matches() =>
+            // Convert a stream not found error to ClassNotFoundException.
+            // Driver sends this explicit acknowledgment to tell us that the 
class was missing.
             throw new ClassNotFoundException(path, e)
+          case NonFatal(e) =>
+            // scalastyle:off throwerror
 
 Review comment:
   `RemoteClassLoaderError` wraps both Error and Exception. It's better to make 
it an Error to not convert an Error to an Exception. In addition, since in 
Spark, most of codes use `NonFatal` so this new Error will still be caught and 
handled.

----------------------------------------------------------------
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