Skip to content

Commit 85e6a22

Browse files
zsxwingAndrew Or
authored andcommitted
[SPARK-13298][CORE][UI] Escape "label" to avoid DAG being broken by some 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 <[email protected]> Closes #11309 from zsxwing/SPARK-13298. (cherry picked from commit a11b399) Signed-off-by: Andrew Or <[email protected]>
1 parent 699644c commit 85e6a22

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/src/main/scala/org/apache/spark/ui/scope/RDDOperationGraph.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ package org.apache.spark.ui.scope
2020
import scala.collection.mutable
2121
import scala.collection.mutable.{StringBuilder, ListBuffer}
2222

23+
import org.apache.commons.lang3.StringEscapeUtils
24+
2325
import org.apache.spark.Logging
2426
import org.apache.spark.scheduler.StageInfo
2527
import org.apache.spark.storage.StorageLevel
26-
import org.apache.spark.util.CallSite
2728

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

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

0 commit comments

Comments
 (0)