Skip to content

Commit

Permalink
[SPARK-13298][CORE][UI] Escape "label" to avoid DAG being broken by s…
Browse files Browse the repository at this point in the history
…ome special character

## What changes were proposed in this pull request?

When there are some special characters (e.g., `"`, `\`) in `label`, DAG will be broken. This patch just escapes `label` to avoid DAG being broken by some special characters

## How was the this patch tested?

Jenkins tests

Author: Shixiong Zhu <shixiong@databricks.com>

Closes #11309 from zsxwing/SPARK-13298.

(cherry picked from commit a11b399)
Signed-off-by: Andrew Or <andrew@databricks.com>
  • Loading branch information
zsxwing authored and Andrew Or committed Feb 23, 2016
1 parent 699644c commit 85e6a22
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ package org.apache.spark.ui.scope
import scala.collection.mutable
import scala.collection.mutable.{StringBuilder, ListBuffer}

import org.apache.commons.lang3.StringEscapeUtils

import org.apache.spark.Logging
import org.apache.spark.scheduler.StageInfo
import org.apache.spark.storage.StorageLevel
import org.apache.spark.util.CallSite

/**
* A representation of a generic cluster graph used for storing information on RDD operations.
Expand Down Expand Up @@ -179,7 +180,7 @@ private[ui] object RDDOperationGraph extends Logging {
/** Return the dot representation of a node in an RDDOperationGraph. */
private def makeDotNode(node: RDDOperationNode): String = {
val label = s"${node.name} [${node.id}]\n${node.callsite}"
s"""${node.id} [label="$label"]"""
s"""${node.id} [label="${StringEscapeUtils.escapeJava(label)}"]"""
}

/** Update the dot representation of the RDDOperationGraph in cluster to subgraph. */
Expand All @@ -188,7 +189,7 @@ private[ui] object RDDOperationGraph extends Logging {
cluster: RDDOperationCluster,
indent: String): Unit = {
subgraph.append(indent).append(s"subgraph cluster${cluster.id} {\n")
subgraph.append(indent).append(s""" label="${cluster.name}";\n""")
.append(indent).append(s""" label="${StringEscapeUtils.escapeJava(cluster.name)}";\n""")
cluster.childNodes.foreach { node =>
subgraph.append(indent).append(s" ${makeDotNode(node)};\n")
}
Expand Down

0 comments on commit 85e6a22

Please sign in to comment.