[SPARK-7187] SerializationDebugger should not crash user code

rxin

Author: Andrew Or <andrew@databricks.com>

Closes #5734 from andrewor14/ser-deb and squashes the following commits:

e8aad6c [Andrew Or] NonFatal
57d0ef4 [Andrew Or] try catch improveException
This commit is contained in:
Andrew Or 2015-04-28 00:38:14 -07:00 committed by Reynold Xin
parent 9e4e82b7bc
commit bf35edd9d4

View file

@ -23,6 +23,7 @@ import java.security.AccessController
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.control.NonFatal
import org.apache.spark.Logging
@ -35,8 +36,15 @@ private[serializer] object SerializationDebugger extends Logging {
*/
def improveException(obj: Any, e: NotSerializableException): NotSerializableException = {
if (enableDebugging && reflect != null) {
new NotSerializableException(
e.getMessage + "\nSerialization stack:\n" + find(obj).map("\t- " + _).mkString("\n"))
try {
new NotSerializableException(
e.getMessage + "\nSerialization stack:\n" + find(obj).map("\t- " + _).mkString("\n"))
} catch {
case NonFatal(t) =>
// Fall back to old exception
logWarning("Exception in serialization debugger", t)
e
}
} else {
e
}