PaperMC/patches/api/Revert-686-Fix-contains-for-default-section-generati.patch
Shane Freeder e185936159 Revert "#686: Fix contains for default section generating real sections"
This commit causes an NPE when getting from the config in some states,
given upstream issue and PR in the works, I have 0 inclination to debug
this

This reverts commit e4358b8217126bbcc3a38b0d17097ad5ab87c50a.
2021-12-05 15:20:52 +00:00

50 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 5 Dec 2021 15:19:10 +0000
Subject: [PATCH] Revert "#686: Fix contains for default section generating
real sections"
This commit causes an NPE when getting from the config in some states,
given upstream issue and PR in the works, I have 0 inclination to debug
this
This reverts commit e4358b8217126bbcc3a38b0d17097ad5ab87c50a.
diff --git a/src/main/java/org/bukkit/configuration/MemorySection.java b/src/main/java/org/bukkit/configuration/MemorySection.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/configuration/MemorySection.java
+++ b/src/main/java/org/bukkit/configuration/MemorySection.java
@@ -0,0 +0,0 @@ public class MemorySection implements ConfigurationSection {
int i1 = -1, i2;
ConfigurationSection section = this;
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
- if (section == null || !section.contains(path.substring(i2, i1), true)) {
+ section = section.getConfigurationSection(path.substring(i2, i1));
+ if (section == null) {
return def;
}
- section = section.getConfigurationSection(path.substring(i2, i1));
}
String key = path.substring(i2);
diff --git a/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java b/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java
+++ b/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java
@@ -0,0 +0,0 @@ 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();