mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
SPIGOT-6274: Reloading configuration does not clear previous values
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
c73564ed4b
commit
d34f1cd453
@ -66,6 +66,8 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
options().header(header);
|
||||
}
|
||||
|
||||
this.map.clear();
|
||||
|
||||
if (input != null) {
|
||||
convertMapsToSections(input, this);
|
||||
}
|
||||
|
@ -206,4 +206,69 @@ public abstract class FileConfigurationTest extends MemoryConfigurationTest {
|
||||
|
||||
assertEquals("", config.saveToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadClear() throws Exception {
|
||||
// Test for SPIGOT-6274 - load does not clear values
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
config.set("test", true);
|
||||
assertTrue(config.contains("test"));
|
||||
assertTrue(config.getBoolean("test"));
|
||||
|
||||
config.loadFromString("");
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadClear2() throws Exception {
|
||||
// Test for SPIGOT-6274 - load does not clear values
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
config.set("test", true);
|
||||
assertTrue(config.contains("test"));
|
||||
assertTrue(config.getBoolean("test"));
|
||||
|
||||
config.loadFromString("other: false"); // Test both null and non-null code paths
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadClear3() throws Exception {
|
||||
// Test for SPIGOT-6274 - load does not clear values
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
config.set("test", true);
|
||||
assertTrue(config.contains("test"));
|
||||
assertTrue(config.getBoolean("test"));
|
||||
|
||||
config.loadFromString("other: false\nsection:\n value: true"); // SPIGOT-6313: Test with section
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
|
||||
assertTrue(config.contains("other"));
|
||||
assertTrue(config.contains("section"));
|
||||
assertTrue(config.contains("section.value"));
|
||||
assertTrue(config.getBoolean("section.value"));
|
||||
|
||||
assertFalse(config.contains("test"));
|
||||
assertFalse(config.getBoolean("test"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user