This is an automated email from the ASF dual-hosted git repository.

mridulm80 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a7d9103d6f [SPARK-43052][CORE] Handle stacktrace with null file name 
in event log
5a7d9103d6f is described below

commit 5a7d9103d6f626c6bb54d072ef54d62f874a9da2
Author: Warren Zhu <[email protected]>
AuthorDate: Wed Apr 26 23:33:05 2023 -0500

    [SPARK-43052][CORE] Handle stacktrace with null file name in event log
    
    ### What changes were proposed in this pull request?
    Handle stacktrace with null file name in event log
    
    ### Why are the changes needed?
    NPE error when handling stacktrace with null file name in event log
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Added test in JsonProtocolSuite
    
    Closes #40687 from warrenzhu25/null-eventlog.
    
    Authored-by: Warren Zhu <[email protected]>
    Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
---
 core/src/main/scala/org/apache/spark/util/JsonProtocol.scala  |  2 +-
 .../test/scala/org/apache/spark/util/JsonProtocolSuite.scala  | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala 
b/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
index 6b75971fc25..eefc68bf91d 100644
--- a/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
+++ b/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
@@ -1558,7 +1558,7 @@ private[spark] object JsonProtocol {
     json.extractElements.map { line =>
       val declaringClass = line.get("Declaring Class").extractString
       val methodName = line.get("Method Name").extractString
-      val fileName = line.get("File Name").extractString
+      val fileName = jsonOption(line.get("File 
Name")).map(_.extractString).orNull
       val lineNumber = line.get("Line Number").extractInt
       new StackTraceElement(declaringClass, methodName, fileName, lineNumber)
     }.toArray
diff --git a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala 
b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
index 3eb0d1378e0..cea6061c07c 100644
--- a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
@@ -809,6 +809,11 @@ class JsonProtocolSuite extends SparkFunSuite {
       
JsonProtocol.taskEndReasonFromJson(exceptionFailureJson).asInstanceOf[ExceptionFailure]
     assert(exceptionFailure.description == null)
   }
+
+  test("SPARK-43052: Handle stackTrace with null file name") {
+    val stackTrace = Seq(new StackTraceElement("class", "method", null, 
-1)).toArray
+    testStackTrace(stackTrace)
+  }
 }
 
 
@@ -904,6 +909,12 @@ private[spark] object JsonProtocolSuite extends Assertions 
{
     assertEquals(reason, newReason)
   }
 
+  private def testStackTrace(stackTrace: Array[StackTraceElement]): Unit = {
+    val newStackTrace = JsonProtocol.stackTraceFromJson(
+      toJsonString(JsonProtocol.stackTraceToJson(stackTrace, _)))
+    assertSeqEquals(stackTrace, newStackTrace, assertStackTraceElementEquals)
+  }
+
   private def testBlockId(blockId: BlockId): Unit = {
     val newBlockId = BlockId(blockId.toString)
     assert(blockId === newBlockId)


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

Reply via email to