You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2023/01/03 02:33:06 UTC
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #39221: [SPARK-41719] [CORE]: SSLOptions sub settings should be set only when ssl is enabled
dongjoon-hyun commented on code in PR #39221:
URL: https://github.com/apache/spark/pull/39221#discussion_r1060249196
##########
core/src/main/scala/org/apache/spark/SSLOptions.scala:
##########
@@ -181,60 +181,64 @@ private[spark] object SSLOptions extends Logging {
ns: String,
defaults: Option[SSLOptions] = None): SSLOptions = {
val enabled = conf.getBoolean(s"$ns.enabled", defaultValue = defaults.exists(_.enabled))
+ if (enabled) {
+ val port = conf.getWithSubstitution(s"$ns.port").map(_.toInt)
+ port.foreach { p =>
+ require(p >= 0, "Port number must be a non-negative value.")
+ }
- val port = conf.getWithSubstitution(s"$ns.port").map(_.toInt)
- port.foreach { p =>
- require(p >= 0, "Port number must be a non-negative value.")
- }
-
- val keyStore = conf.getWithSubstitution(s"$ns.keyStore").map(new File(_))
+ val keyStore = conf.getWithSubstitution(s"$ns.keyStore").map(new File(_))
.orElse(defaults.flatMap(_.keyStore))
- val keyStorePassword = conf.getWithSubstitution(s"$ns.keyStorePassword")
+ val keyStorePassword = conf.getWithSubstitution(s"$ns.keyStorePassword")
.orElse(Option(hadoopConf.getPassword(s"$ns.keyStorePassword")).map(new String(_)))
.orElse(defaults.flatMap(_.keyStorePassword))
- val keyPassword = conf.getWithSubstitution(s"$ns.keyPassword")
+ val keyPassword = conf.getWithSubstitution(s"$ns.keyPassword")
.orElse(Option(hadoopConf.getPassword(s"$ns.keyPassword")).map(new String(_)))
.orElse(defaults.flatMap(_.keyPassword))
- val keyStoreType = conf.getWithSubstitution(s"$ns.keyStoreType")
+ val keyStoreType = conf.getWithSubstitution(s"$ns.keyStoreType")
.orElse(defaults.flatMap(_.keyStoreType))
- val needClientAuth =
- conf.getBoolean(s"$ns.needClientAuth", defaultValue = defaults.exists(_.needClientAuth))
+ val needClientAuth =
+ conf.getBoolean(s"$ns.needClientAuth", defaultValue = defaults.exists(_.needClientAuth))
- val trustStore = conf.getWithSubstitution(s"$ns.trustStore").map(new File(_))
+ val trustStore = conf.getWithSubstitution(s"$ns.trustStore").map(new File(_))
.orElse(defaults.flatMap(_.trustStore))
- val trustStorePassword = conf.getWithSubstitution(s"$ns.trustStorePassword")
+ val trustStorePassword = conf.getWithSubstitution(s"$ns.trustStorePassword")
.orElse(Option(hadoopConf.getPassword(s"$ns.trustStorePassword")).map(new String(_)))
.orElse(defaults.flatMap(_.trustStorePassword))
- val trustStoreType = conf.getWithSubstitution(s"$ns.trustStoreType")
+ val trustStoreType = conf.getWithSubstitution(s"$ns.trustStoreType")
.orElse(defaults.flatMap(_.trustStoreType))
- val protocol = conf.getWithSubstitution(s"$ns.protocol")
+ val protocol = conf.getWithSubstitution(s"$ns.protocol")
.orElse(defaults.flatMap(_.protocol))
- val enabledAlgorithms = conf.getWithSubstitution(s"$ns.enabledAlgorithms")
+ val enabledAlgorithms = conf.getWithSubstitution(s"$ns.enabledAlgorithms")
.map(_.split(",").map(_.trim).filter(_.nonEmpty).toSet)
.orElse(defaults.map(_.enabledAlgorithms))
.getOrElse(Set.empty)
- new SSLOptions(
- enabled,
- port,
- keyStore,
- keyStorePassword,
- keyPassword,
- keyStoreType,
- needClientAuth,
- trustStore,
- trustStorePassword,
- trustStoreType,
- protocol,
- enabledAlgorithms)
+ new SSLOptions(
+ enabled,
+ port,
+ keyStore,
+ keyStorePassword,
+ keyPassword,
+ keyStoreType,
+ needClientAuth,
+ trustStore,
+ trustStorePassword,
+ trustStoreType,
+ protocol,
+ enabledAlgorithms)
+ } else {
+ new SSLOptions(
+ enabled)
Review Comment:
In this case, one liner is preferred.
```scala
- new SSLOptions(
- enabled)
+ new SSLOptions(enabled)
```
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org