Skip to content

Commit bf35edd

Browse files
Andrew Orrxin
authored andcommitted
[SPARK-7187] SerializationDebugger should not crash user code
rxin Author: Andrew Or <[email protected]> Closes apache#5734 from andrewor14/ser-deb and squashes the following commits: e8aad6c [Andrew Or] NonFatal 57d0ef4 [Andrew Or] try catch improveException
1 parent 9e4e82b commit bf35edd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/src/main/scala/org/apache/spark/serializer/SerializationDebugger.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import java.security.AccessController
2323

2424
import scala.annotation.tailrec
2525
import scala.collection.mutable
26+
import scala.util.control.NonFatal
2627

2728
import org.apache.spark.Logging
2829

@@ -35,8 +36,15 @@ private[serializer] object SerializationDebugger extends Logging {
3536
*/
3637
def improveException(obj: Any, e: NotSerializableException): NotSerializableException = {
3738
if (enableDebugging && reflect != null) {
38-
new NotSerializableException(
39-
e.getMessage + "\nSerialization stack:\n" + find(obj).map("\t- " + _).mkString("\n"))
39+
try {
40+
new NotSerializableException(
41+
e.getMessage + "\nSerialization stack:\n" + find(obj).map("\t- " + _).mkString("\n"))
42+
} catch {
43+
case NonFatal(t) =>
44+
// Fall back to old exception
45+
logWarning("Exception in serialization debugger", t)
46+
e
47+
}
4048
} else {
4149
e
4250
}

0 commit comments

Comments
 (0)