config manager: treat null and empty string equally in setDefaultConfiguration

The config manager treats null and empty string as equal and will unset
config values which are set to the empty string with the config client.

This fixes the config manager applying default config values which are the
empty string when the current value is null, causing it to send an
unnecessary unset request
This commit is contained in:
Adam
2019-06-24 13:20:38 -04:00
parent 4b0f8526ec
commit 61ea6cf217

View File

@@ -523,7 +523,10 @@ public class ConfigManager
String current = getConfiguration(group.value(), item.keyName());
String valueString = objectToString(defaultValue);
if (Objects.equals(current, valueString))
// null and the empty string are treated identically in sendConfig and treated as an unset
// If a config value defaults to "" and the current value is null, it will cause an extra
// unset to be sent, so treat them as equal
if (Objects.equals(current, valueString) || (Strings.isNullOrEmpty(current) && Strings.isNullOrEmpty(valueString)))
{
continue; // already set to the default value
}