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:01:14 -0700
commit1c12b0b5ca7cffa6fff4341ebc2823938601f71e (patch)
tree4847540e02f0acb3cc7286995ddccd96a23833c8 /sql
parent3bd32f023d9bd83da7afab37fffe614064df3e6b (diff)
downloadspark-1c12b0b5ca7cffa6fff4341ebc2823938601f71e.tar.gz
spark-1c12b0b5ca7cffa6fff4341ebc2823938601f71e.tar.bz2
spark-1c12b0b5ca7cffa6fff4341ebc2823938601f71e.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. (cherry picked from commit 32516f866a32d51bfaa04685ae77ba216b4202d9) Signed-off-by: Reynold Xin <rxin@apache.org>
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 64b950331e..7c93de3e38 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 {
@@ -54,11 +56,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)