From c73564ed4b0551c18f86c902646f78a2393db002 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 12 Jan 2021 11:34:31 +1100 Subject: [PATCH] SPIGOT-6313: Revert "SPIGOT-6274: Reloading configuration does not clear previous values" This reverts commit 885c2247d1a4156c3ad20a4983a60299b3719f26. By: md_5 --- .../configuration/file/YamlConfiguration.java | 3 -- .../file/FileConfigurationTest.java | 40 ------------------- 2 files changed, 43 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java index 8f99f0e307..be8d35f156 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java @@ -68,13 +68,10 @@ public class YamlConfiguration extends FileConfiguration { if (input != null) { convertMapsToSections(input, this); - } else { - this.map.clear(); } } protected void convertMapsToSections(@NotNull Map input, @NotNull ConfigurationSection section) { - this.map.clear(); for (Map.Entry entry : input.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); diff --git a/paper-api/src/test/java/org/bukkit/configuration/file/FileConfigurationTest.java b/paper-api/src/test/java/org/bukkit/configuration/file/FileConfigurationTest.java index 7dd31fd165..a996753b93 100644 --- a/paper-api/src/test/java/org/bukkit/configuration/file/FileConfigurationTest.java +++ b/paper-api/src/test/java/org/bukkit/configuration/file/FileConfigurationTest.java @@ -206,44 +206,4 @@ 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")); - } }