Commit 0378de7b authored by dreis2211's avatar dreis2211 Committed by Phillip Webb

Optimize SystemEnvironmentPropertyMapper

See gh-21523
parent f8d6d9a4
......@@ -116,6 +116,16 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
if (!hasDashedEntries(name)) {
return false;
}
StringBuilder legacyCompatibleName = buildLegacyCompatibleName(name);
try {
return ConfigurationPropertyName.of(legacyCompatibleName).isAncestorOf(candidate);
}
catch (Exception ex) {
return false;
}
}
private StringBuilder buildLegacyCompatibleName(ConfigurationPropertyName name) {
StringBuilder legacyCompatibleName = new StringBuilder();
for (int i = 0; i < name.getNumberOfElements(); i++) {
if (i != 0) {
......@@ -123,8 +133,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
}
legacyCompatibleName.append(name.getElement(i, Form.DASHED).replace('-', '.'));
}
return ConfigurationPropertyName.isValid(legacyCompatibleName)
&& ConfigurationPropertyName.of(legacyCompatibleName).isAncestorOf(candidate);
return legacyCompatibleName;
}
boolean hasDashedEntries(ConfigurationPropertyName name) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment