Skip to content

Commit

Permalink
Check for non empty files.
Browse files Browse the repository at this point in the history
  • Loading branch information
mccheah committed Dec 7, 2018
1 parent a6a44c6 commit 9443646
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/scala/org/apache/spark/SecurityManager.scala
Expand Up @@ -397,7 +397,9 @@ private[spark] class SecurityManager(
case k8sRegex() =>
val secretFile = new File(secretFilePath)
require(secretFile.isFile, s"No file found containing the secret key at $secretFilePath.")
Base64.getEncoder.encodeToString(Files.readAllBytes(secretFile.toPath))
val base64Key = Base64.getEncoder.encodeToString(Files.readAllBytes(secretFile.toPath))
require(!base64Key.isEmpty, s"Secret key from file located at $secretFilePath is empty.")
base64Key
case _ =>
throw new IllegalArgumentException(
"Secret keys provided via files is only allowed in Kubernetes mode.")
Expand Down

0 comments on commit 9443646

Please sign in to comment.