Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private object ConfigHelpers {

def toNumber[T](s: String, converter: String => T, key: String, configType: String): T = {
try {
converter(s)
converter(s.trim)
} catch {
case _: NumberFormatException =>
throw new IllegalArgumentException(s"$key should be $configType, but was $s")
Expand All @@ -37,7 +37,7 @@ private object ConfigHelpers {

def toBoolean(s: String, key: String): Boolean = {
try {
s.toBoolean
s.trim.toBoolean
} catch {
case _: IllegalArgumentException =>
throw new IllegalArgumentException(s"$key should be boolean, but was $s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class SQLConfEntrySuite extends SparkFunSuite {
assert(conf.getConfString(key) === "20")
assert(conf.getConf(confEntry, 5) === 20)

conf.setConfString(key, " 20")
assert(conf.getConf(confEntry, 5) === 20)

val e = intercept[IllegalArgumentException] {
conf.setConfString(key, "abc")
}
Expand Down Expand Up @@ -75,6 +78,8 @@ class SQLConfEntrySuite extends SparkFunSuite {
assert(conf.getConfString(key) === "true")
assert(conf.getConf(confEntry, false) === true)

conf.setConfString(key, " true ")
assert(conf.getConf(confEntry, false) === true)
val e = intercept[IllegalArgumentException] {
conf.setConfString(key, "abc")
}
Expand Down