Skip to content

Commit

Permalink
[SPARK-38579][SQL][WEBUI] Requesting Restful API can cause NullPointe…
Browse files Browse the repository at this point in the history
…rException

### 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 apache#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 apache#35884 from yym1995/fix-npe.

Lead-authored-by: Yimin <yimin.y@outlook.com>
Co-authored-by: Yimin Yang <26797163+yym1995@users.noreply.github.com>
Signed-off-by: Yuming Wang <yumwang@ebay.com>
(cherry picked from commit 99992a4)
Signed-off-by: Yuming Wang <yumwang@ebay.com>
  • Loading branch information
2 people authored and wangyum committed Mar 22, 2022
1 parent e78038b commit c3aace7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c3aace7

Please sign in to comment.