Skip to content

Commit a11b399

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.
1 parent 33ef3aa commit a11b399

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.{ListBuffer, StringBuilder}
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.
@@ -183,7 +184,7 @@ private[ui] object RDDOperationGraph extends Logging {
183184
/** Return the dot representation of a node in an RDDOperationGraph. */
184185
private def makeDotNode(node: RDDOperationNode): String = {
185186
val label = s"${node.name} [${node.id}]\n${node.callsite}"
186-
s"""${node.id} [label="$label"]"""
187+
s"""${node.id} [label="${StringEscapeUtils.escapeJava(label)}"]"""
187188
}
188189

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

0 commit comments

Comments
 (0)