Skip to content

Commit 1c12b0b

Browse files
committed
[SPARK-2409] Make SQLConf thread safe.
Author: Reynold Xin <[email protected]> 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 32516f8) Signed-off-by: Reynold Xin <[email protected]>
1 parent 3bd32f0 commit 1c12b0b

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

@@ -54,11 +56,9 @@ trait SQLConf {
5456
Option(settings.get(key)).getOrElse(defaultValue)
5557
}
5658

57-
def getAll: Array[(String, String)] = settings.asScala.toArray
59+
def getAll: Array[(String, String)] = settings.synchronized { settings.asScala.toArray }
5860

59-
def getOption(key: String): Option[String] = {
60-
Option(settings.get(key))
61-
}
61+
def getOption(key: String): Option[String] = Option(settings.get(key))
6262

6363
def contains(key: String): Boolean = settings.containsKey(key)
6464

0 commit comments

Comments
 (0)