mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
#686: Fix contains for default section generating real sections
This commit is contained in:
parent
0912ace4df
commit
e4358b8217
2 changed files with 12 additions and 2 deletions
|
@ -251,10 +251,10 @@ public class MemorySection implements ConfigurationSection {
|
|||
int i1 = -1, i2;
|
||||
ConfigurationSection section = this;
|
||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||
section = section.getConfigurationSection(path.substring(i2, i1));
|
||||
if (section == null) {
|
||||
if (section == null || !section.contains(path.substring(i2, i1), true)) {
|
||||
return def;
|
||||
}
|
||||
section = section.getConfigurationSection(path.substring(i2, i1));
|
||||
}
|
||||
|
||||
String key = path.substring(i2);
|
||||
|
|
|
@ -110,6 +110,16 @@ public abstract class ConfigurationSectionTest {
|
|||
assertTrue(section.contains("doenst-exist-two", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContainsDoesNotCreateSection() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
section.addDefault("notExistingSection.Value", "Test String");
|
||||
|
||||
assertFalse(section.contains("notExistingSection", true));
|
||||
assertFalse(section.contains("notExistingSection.Value", true));
|
||||
assertFalse(section.contains("notExistingSection", true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSet() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
|
|
Loading…
Add table
Reference in a new issue