From e919ac47513085eaac500627a1791eb1d62c781e Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Wed, 8 Jul 2020 10:01:10 +0200 Subject: [PATCH] ConnectionProviderSuite fix --- .../jdbc/connection/ConnectionProvider.scala | 4 ++-- .../connection/ConnectionProviderSuite.scala | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProvider.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProvider.scala index 27611a844fcb8..5c167cc7c7692 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProvider.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProvider.scala @@ -27,9 +27,9 @@ import org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions import org.apache.spark.util.Utils private[jdbc] object ConnectionProvider extends Logging { - val providers = loadProviders() + private val providers = loadProviders() - private def loadProviders(): Seq[JdbcConnectionProvider] = { + def loadProviders(): Seq[JdbcConnectionProvider] = { val loader = ServiceLoader.load(classOf[JdbcConnectionProvider], Utils.getContextOrSparkClassLoader) val providers = mutable.ArrayBuffer[JdbcConnectionProvider]() diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProviderSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProviderSuite.scala index a5b16d565b884..a48dbdebea7e9 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProviderSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/jdbc/connection/ConnectionProviderSuite.scala @@ -22,16 +22,16 @@ import javax.security.auth.login.Configuration class ConnectionProviderSuite extends ConnectionProviderSuiteBase { test("All built-in provides must be loaded") { IntentionallyFaultyConnectionProvider.constructed = false - assert(ConnectionProvider.providers.exists(_.isInstanceOf[BasicConnectionProvider])) - assert(ConnectionProvider.providers.exists(_.isInstanceOf[DB2ConnectionProvider])) - assert(ConnectionProvider.providers.exists(_.isInstanceOf[MariaDBConnectionProvider])) - assert(ConnectionProvider.providers.exists(_.isInstanceOf[MSSQLConnectionProvider])) - assert(ConnectionProvider.providers.exists(_.isInstanceOf[PostgresConnectionProvider])) - assert(ConnectionProvider.providers.exists(_.isInstanceOf[OracleConnectionProvider])) + val providers = ConnectionProvider.loadProviders() + assert(providers.exists(_.isInstanceOf[BasicConnectionProvider])) + assert(providers.exists(_.isInstanceOf[DB2ConnectionProvider])) + assert(providers.exists(_.isInstanceOf[MariaDBConnectionProvider])) + assert(providers.exists(_.isInstanceOf[MSSQLConnectionProvider])) + assert(providers.exists(_.isInstanceOf[PostgresConnectionProvider])) + assert(providers.exists(_.isInstanceOf[OracleConnectionProvider])) assert(IntentionallyFaultyConnectionProvider.constructed) - assert(!ConnectionProvider.providers. - exists(_.isInstanceOf[IntentionallyFaultyConnectionProvider])) - assert(ConnectionProvider.providers.size === 6) + assert(!providers.exists(_.isInstanceOf[IntentionallyFaultyConnectionProvider])) + assert(providers.size === 6) } test("Multiple security configs must be reachable") {