aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorReynold Xin <rxin@apache.org>2014-07-08 14:00:47 -0700
committerReynold Xin <rxin@apache.org>2014-07-08 14:00:47 -0700
commit32516f866a32d51bfaa04685ae77ba216b4202d9 (patch)
treea5b38431b1a2ed643c099461c5cbca5f3a439155 /sql
parentb520b6453ed76926108e0bdd56114d16e1d86850 (diff)
downloadspark-32516f866a32d51bfaa04685ae77ba216b4202d9.tar.gz
spark-32516f866a32d51bfaa04685ae77ba216b4202d9.tar.bz2
spark-32516f866a32d51bfaa04685ae77ba216b4202d9.zip
[SPARK-2409] Make SQLConf thread safe.
Author: Reynold Xin <rxin@apache.org> Closes #1334 from rxin/sqlConfThreadSafetuy and squashes the following commits: c1e0a5a [Reynold Xin] Fixed the duplicate comment. 7614372 [Reynold Xin] [SPARK-2409] Make SQLConf thread safe.
Diffstat (limited to 'sql')
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala b/sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
index 95ed0f2850..b6fb46a3ac 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
@@ -25,7 +25,9 @@ import scala.collection.JavaConverters._
* SQLConf holds mutable config parameters and hints. These can be set and
* queried either by passing SET commands into Spark SQL's DSL
* functions (sql(), hql(), etc.), or by programmatically using setters and
- * getters of this class. This class is thread-safe.
+ * getters of this class.
+ *
+ * SQLConf is thread-safe (internally synchronized so safe to be used in multiple threads).
*/
trait SQLConf {
@@ -71,11 +73,9 @@ trait SQLConf {
Option(settings.get(key)).getOrElse(defaultValue)
}
- def getAll: Array[(String, String)] = settings.asScala.toArray
+ def getAll: Array[(String, String)] = settings.synchronized { settings.asScala.toArray }
- def getOption(key: String): Option[String] = {
- Option(settings.get(key))
- }
+ def getOption(key: String): Option[String] = Option(settings.get(key))
def contains(key: String): Boolean = settings.containsKey(key)