code review changes.

This commit is contained in:
Tyler Benson 2019-03-20 17:09:39 -07:00
parent 715af67e70
commit 4187bf3eb0
2 changed files with 9 additions and 8 deletions

View File

@ -447,6 +447,7 @@ public class Config {
}
private static Map<String, String> parseMap(final String str, final String settingName) {
// If we ever want to have default values besides an empty map, this will need to change.
if (str == null || str.trim().isEmpty()) {
return Collections.emptyMap();
}
@ -476,12 +477,11 @@ public class Config {
private static Set<Integer> parseIntegerRangeSet(String str, final String settingName)
throws NumberFormatException {
if (str == null || str.trim().isEmpty()) {
return Collections.emptySet();
if (str == null) {
str = "";
}
str = str.replaceAll("\\s", "");
if (!str.matches("\\d{3}(?:-\\d{3})*(?:,\\d{3}(?:-\\d{3})*)*")) {
if (!str.matches("\\d{3}(?:-\\d{3})?(?:,\\d{3}(?:-\\d{3})?)*")) {
log.warn(
"Invalid config for {}: '{}'. Must be formatted like '400-403,405,410-499'.",
settingName,

View File

@ -474,11 +474,11 @@ class ConfigTest extends Specification {
then:
if (expected) {
config.httpServerErrorStatuses == expected.toSet()
config.httpClientErrorStatuses == expected.toSet()
assert config.httpServerErrorStatuses == expected.toSet()
assert config.httpClientErrorStatuses == expected.toSet()
} else {
config.httpServerErrorStatuses == Config.DEFAULT_HTTP_SERVER_ERROR_STATUSES
config.httpClientErrorStatuses == Config.DEFAULT_HTTP_CLIENT_ERROR_STATUSES
assert config.httpServerErrorStatuses == Config.DEFAULT_HTTP_SERVER_ERROR_STATUSES
assert config.httpClientErrorStatuses == Config.DEFAULT_HTTP_CLIENT_ERROR_STATUSES
}
where:
@ -487,6 +487,7 @@ class ConfigTest extends Specification {
"a" | null
"" | null
"1000" | null
"100-200-300" | null
"500" | [500]
"100,999" | [100, 999]
"999-888" | 888..999