Fix `YamlConfiruration#getKeys("")` not returning root node keys

This commit is contained in:
Christian Koop 2022-06-26 01:35:42 +02:00
parent 2683bc12c0
commit 885cc9a87e
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 7 additions and 3 deletions

View File

@ -96,6 +96,10 @@ public class YamlConfiguration implements IConfiguration, HeaderCommentable, Nod
return Collections.emptySet();
}
if (key.equals("")) {
return Collections.unmodifiableSet(this.values.keySet());
}
Map<String, ?> innerMap = null;
try {
@ -260,8 +264,8 @@ public class YamlConfiguration implements IConfiguration, HeaderCommentable, Nod
@Override
public String toString() {
return "YamlConfiguration{" +
"values=" + values +
", headerComment=" + headerComment +
"values=" + this.values +
", headerComment=" + this.headerComment +
'}';
}

View File

@ -274,7 +274,7 @@ class YamlConfigurationTest {
final YamlConfiguration cfg = new YamlConfiguration();
cfg.load(new StringReader(inputYaml));
assertTrue(cfg.getKeys("").isEmpty());
assertEquals(2, cfg.getKeys("").size());
assertTrue(cfg.getKeys(null).isEmpty());
assertTrue(cfg.getKeys("primitives.map.key.non-existing-subkey").isEmpty());