From 3797f8b161ffb990fc52efb74c2c7e5715ecb233 Mon Sep 17 00:00:00 2001 From: Tim Ellison Date: Sun, 28 Jun 2015 14:38:25 +0100 Subject: [PATCH] Remove unnecessary use of Option to improve clarity, and fix import style ordering. --- .../scala/org/apache/spark/SSLOptions.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/SSLOptions.scala b/core/src/main/scala/org/apache/spark/SSLOptions.scala index 29153c1fa4515..3b47100afeee4 100644 --- a/core/src/main/scala/org/apache/spark/SSLOptions.scala +++ b/core/src/main/scala/org/apache/spark/SSLOptions.scala @@ -18,13 +18,13 @@ package org.apache.spark import java.io.{File, FileInputStream} +import java.security.{KeyStore, NoSuchAlgorithmException} + +import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory} import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory} import org.eclipse.jetty.util.ssl.SslContextFactory -import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory} -import java.security.{KeyStore, NoSuchAlgorithmException} - /** * SSLOptions class is a common container for SSL configuration options. It offers methods to * generate specific objects to configure SSL for different communication protocols. @@ -111,22 +111,22 @@ private[spark] case class SSLOptions( * are supported by the current Java security provider for this protocol. */ private val supportedAlgorithms: Set[String] = { - var context: Option[SSLContext] = Some(SSLContext.getDefault) + var context: SSLContext = null try { - context = Some(SSLContext.getInstance(protocol.orNull)) + context = SSLContext.getInstance(protocol.orNull) /* The set of supported algorithms does not depend upon the keys, trust, or rng, although they will influence which algorithms are eventually used. */ - context.foreach(_.init(null, null, null)) + context.init(null, null, null) } catch { case npe: NullPointerException => logDebug("No SSL protocol specified") + context = SSLContext.getDefault case nsa: NoSuchAlgorithmException => logDebug(s"No support for requested SSL protocol ${protocol.get}") + context = SSLContext.getDefault } - val providerAlgorithms = context - .map(_.getServerSocketFactory.getSupportedCipherSuites.toSet) - .getOrElse(Set.empty) + val providerAlgorithms = context.getServerSocketFactory.getSupportedCipherSuites.toSet // Log which algorithms we are discarding (enabledAlgorithms &~ providerAlgorithms).foreach { cipher =>