Skip to content
Merged
Changes from 1 commit
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
Next Next commit
If invalid value is set for a property in settings.properties, defaul…
…t value should be applied #1437
  • Loading branch information
Vassiliy-Kudryashov committed Dec 6, 2022
commit a47bc27d10d6d1b52cb3d1fef3db12836df0a39b
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ abstract class AbstractSettings(
return container.settingFor(defaultValue, null, converter)
}

protected fun getBooleanProperty(defaultValue: Boolean) = getProperty(defaultValue, converter = String::toBoolean)
protected fun getBooleanProperty(defaultValue: Boolean) = getProperty(defaultValue, converter = {
//Invalid values shouldn't be parsed as "false"
if (it.equals("true", true)) true
else if (it.equals("false", true)) false
else defaultValue
})
protected fun getIntProperty(defaultValue: Int) = getProperty(defaultValue, converter = String::toInt)
protected fun getIntProperty(defaultValue: Int, minValue: Int, maxValue: Int) = getProperty(defaultValue, Triple(minValue, maxValue, Comparator(Integer::compare)), String::toInt)
protected fun getLongProperty(defaultValue: Long) = getProperty(defaultValue, converter = String::toLong)
Expand Down