You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by yu...@apache.org on 2022/03/22 10:27:57 UTC

[spark] branch branch-3.3 updated: [SPARK-38579][SQL][WEBUI] Requesting Restful API can cause NullPointerException

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

yumwang pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new bbe485f  [SPARK-38579][SQL][WEBUI] Requesting Restful API can cause NullPointerException
bbe485f is described below

commit bbe485fe3778de38680feee23785ebe1e2da9d4f
Author: Yimin <yi...@outlook.com>
AuthorDate: Tue Mar 22 18:24:12 2022 +0800

    [SPARK-38579][SQL][WEBUI] Requesting Restful API can cause NullPointerException
    
    ### What changes were proposed in this pull request?
    
    Added null check for `exec.metricValues`.
    
    ### Why are the changes needed?
    
    When requesting Restful API  {baseURL}/api/v1/applications/$appId/sql/$executionId which is introduced by this PR https://github.com/apache/spark/pull/28208, it can cause NullPointerException. The root cause is, when calling method doUpdate() of `LiveExecutionData`, `metricsValues` can be null. Then, when statement `printableMetrics(graph.allNodes, exec.metricValues)` is executed, it will throw NullPointerException.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Tested manually.
    
    Closes #35884 from yym1995/fix-npe.
    
    Lead-authored-by: Yimin <yi...@outlook.com>
    Co-authored-by: Yimin Yang <26...@users.noreply.github.com>
    Signed-off-by: Yuming Wang <yu...@ebay.com>
    (cherry picked from commit 99992a4e050a00564049be6938f5734876c17518)
    Signed-off-by: Yuming Wang <yu...@ebay.com>
---
 .../main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala b/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
index c7599f8..4dd96e5 100644
--- a/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
+++ b/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
@@ -94,7 +94,11 @@ private[v1] class SqlResource extends BaseAppResource {
 
     val duration = exec.completionTime.getOrElse(new Date()).getTime - exec.submissionTime
     val planDetails = if (planDescription) exec.physicalPlanDescription else ""
-    val nodes = if (details) printableMetrics(graph.allNodes, exec.metricValues) else Seq.empty
+    val nodes = if (details) {
+      printableMetrics(graph.allNodes, Option(exec.metricValues).getOrElse(Map.empty))
+    } else {
+      Seq.empty
+    }
     val edges = if (details) graph.edges else Seq.empty
 
     new ExecutionData(

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org