Skip to content

Commit 3797f8b

Browse files
committed
Remove unnecessary use of Option to improve clarity, and fix import style ordering.
1 parent 4b5c89f commit 3797f8b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

core/src/main/scala/org/apache/spark/SSLOptions.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
package org.apache.spark
1919

2020
import java.io.{File, FileInputStream}
21+
import java.security.{KeyStore, NoSuchAlgorithmException}
22+
23+
import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory}
2124

2225
import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory}
2326
import org.eclipse.jetty.util.ssl.SslContextFactory
2427

25-
import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory}
26-
import java.security.{KeyStore, NoSuchAlgorithmException}
27-
2828
/**
2929
* SSLOptions class is a common container for SSL configuration options. It offers methods to
3030
* generate specific objects to configure SSL for different communication protocols.
@@ -111,22 +111,22 @@ private[spark] case class SSLOptions(
111111
* are supported by the current Java security provider for this protocol.
112112
*/
113113
private val supportedAlgorithms: Set[String] = {
114-
var context: Option[SSLContext] = Some(SSLContext.getDefault)
114+
var context: SSLContext = null
115115
try {
116-
context = Some(SSLContext.getInstance(protocol.orNull))
116+
context = SSLContext.getInstance(protocol.orNull)
117117
/* The set of supported algorithms does not depend upon the keys, trust, or
118118
rng, although they will influence which algorithms are eventually used. */
119-
context.foreach(_.init(null, null, null))
119+
context.init(null, null, null)
120120
} catch {
121121
case npe: NullPointerException =>
122122
logDebug("No SSL protocol specified")
123+
context = SSLContext.getDefault
123124
case nsa: NoSuchAlgorithmException =>
124125
logDebug(s"No support for requested SSL protocol ${protocol.get}")
126+
context = SSLContext.getDefault
125127
}
126128

127-
val providerAlgorithms = context
128-
.map(_.getServerSocketFactory.getSupportedCipherSuites.toSet)
129-
.getOrElse(Set.empty)
129+
val providerAlgorithms = context.getServerSocketFactory.getSupportedCipherSuites.toSet
130130

131131
// Log which algorithms we are discarding
132132
(enabledAlgorithms &~ providerAlgorithms).foreach { cipher =>

0 commit comments

Comments
 (0)