Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2639,9 +2639,12 @@ private[spark] object Utils extends Logging {
* Redact the sensitive information in the given string.
*/
def redact(conf: SparkConf, text: String): String = {
if (text == null || text.isEmpty || !conf.contains(STRING_REDACTION_PATTERN)) return text
val regex = conf.get(STRING_REDACTION_PATTERN).get
regex.replaceAllIn(text, REDACTION_REPLACEMENT_TEXT)
if (text == null || text.isEmpty || conf == null || !conf.contains(STRING_REDACTION_PATTERN)) {
text
} else {
val regex = conf.get(STRING_REDACTION_PATTERN).get
regex.replaceAllIn(text, REDACTION_REPLACEMENT_TEXT)
}
}

private def redact(redactionPattern: Regex, kvs: Seq[(String, String)]): Seq[(String, String)] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trait DataSourceScanExec extends LeafExecNode with CodegenSupport {
* Shorthand for calling redactString() without specifying redacting rules
*/
private def redact(text: String): String = {
Utils.redact(SparkSession.getActiveSession.get.sparkContext.conf, text)
Utils.redact(SparkSession.getActiveSession.map(_.sparkContext.conf).orNull, text)
}
}

Expand Down