yaooqinn commented on a change in pull request #27721: [SPARK-30970][K8S][Core]
Fix NPE while resolving k8s master url
URL: https://github.com/apache/spark/pull/27721#discussion_r385044558
##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -2772,17 +2772,13 @@ private[spark] object Utils extends Logging {
}
val masterScheme = new URI(masterWithoutK8sPrefix).getScheme
- val resolvedURL = masterScheme.toLowerCase(Locale.ROOT) match {
- case "https" =>
+
+ val resolvedURL = Option(masterScheme).map(_.toLowerCase(Locale.ROOT))
match {
+ case Some("https") =>
masterWithoutK8sPrefix
- case "http" =>
+ case Some("http") =>
logWarning("Kubernetes master URL uses HTTP instead of HTTPS.")
masterWithoutK8sPrefix
- case null =>
- val resolvedURL = s"https://$masterWithoutK8sPrefix"
- logInfo("No scheme specified for kubernetes master URL, so defaulting
to https. Resolved " +
- s"URL is $resolvedURL.")
- resolvedURL
case _ =>
Review comment:
if the scheme is undefined and the uri may be valid,then it will be handled
by
https://github.com/apache/spark/pull/27721/files#diff-d239aee594001f8391676e1047a0381eL2767-L2771
. So,the case None here means the uri is invalid
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]