Skip to content

Commit 32516f8

Browse files
committed
[SPARK-2409] Make SQLConf thread safe.
Author: Reynold Xin <[email protected]> Closes apache#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.
1 parent b520b64 commit 32516f8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import scala.collection.JavaConverters._
2525
* SQLConf holds mutable config parameters and hints. These can be set and
2626
* queried either by passing SET commands into Spark SQL's DSL
2727
* functions (sql(), hql(), etc.), or by programmatically using setters and
28-
* getters of this class. This class is thread-safe.
28+
* getters of this class.
29+
*
30+
* SQLConf is thread-safe (internally synchronized so safe to be used in multiple threads).
2931
*/
3032
trait SQLConf {
3133

@@ -71,11 +73,9 @@ trait SQLConf {
7173
Option(settings.get(key)).getOrElse(defaultValue)
7274
}
7375

74-
def getAll: Array[(String, String)] = settings.asScala.toArray
76+
def getAll: Array[(String, String)] = settings.synchronized { settings.asScala.toArray }
7577

76-
def getOption(key: String): Option[String] = {
77-
Option(settings.get(key))
78-
}
78+
def getOption(key: String): Option[String] = Option(settings.get(key))
7979

8080
def contains(key: String): Boolean = settings.containsKey(key)
8181

0 commit comments

Comments
 (0)