Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dilipbiswal committed Apr 5, 2017
1 parent 2eb900b commit 6423b51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ private[spark] class TypedConfigBuilder[T](

/** Creates a [[ConfigEntry]] with a function has a default value */
def createWithDefaultFunction(defaultFunc: () => T): ConfigEntry[T] = {
val entry =
new ConfigEntryWithDefaultFunction[T](parent.key, defaultFunc, converter,
val entry = new ConfigEntryWithDefaultFunction[T](parent.key, defaultFunc, converter,
stringConverter, parent._doc, parent._public)
parent._onCreate.foreach(_ (entry))
entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.spark.internal.config

import java.util.TimeZone
import java.util.concurrent.TimeUnit

import org.apache.spark.{SparkConf, SparkFunSuite}
Expand Down Expand Up @@ -51,6 +52,26 @@ class ConfigEntrySuite extends SparkFunSuite {
assert(conf.get(dConf) === 20.0)
}

test("conf entry: timezone") {
val tzStart = TimeZone.getDefault().getID()
val conf = new SparkConf()
val dConf = ConfigBuilder(testKey("tz"))
.stringConf
.createWithDefaultFunction(() => TimeZone.getDefault().getID())

val tzConf = conf.get(dConf)
assert(tzStart === tzConf)

// Pick a timezone which is not the current timezone
val availableTzs: Seq[String] = TimeZone.getAvailableIDs();
val newTz = availableTzs.find(_ != tzStart).getOrElse(tzStart)
TimeZone.setDefault(TimeZone.getTimeZone(newTz))

val tzChanged = conf.get(dConf)
assert(tzChanged === newTz)
TimeZone.setDefault(TimeZone.getTimeZone(tzStart))
}

test("conf entry: boolean") {
val conf = new SparkConf()
val bConf = ConfigBuilder(testKey("boolean")).booleanConf.createWithDefault(false)
Expand Down

0 comments on commit 6423b51

Please sign in to comment.