From 397d0f284af523a9ed77d58eea32f57e2e8f9155 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 9 Dec 2011 15:50:20 +0000 Subject: [PATCH] Fixed MemorySection list methods' return types + NPEs. This fixes BUKKIT-213, thanks to Sleaker --- .../bukkit/configuration/MemorySection.java | 63 ++++++++++++++++--- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/bukkit/configuration/MemorySection.java b/src/main/java/org/bukkit/configuration/MemorySection.java index 68254d0a..7f4ea7cf 100644 --- a/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/src/main/java/org/bukkit/configuration/MemorySection.java @@ -445,12 +445,17 @@ public class MemorySection implements ConfigurationSection { return val instanceof List; } - public List getStringList(String path) { + public List getStringList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -462,12 +467,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getIntegerList(String path) { + public List getIntegerList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -497,12 +507,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getBooleanList(String path) { + public List getBooleanList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -520,12 +535,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getDoubleList(String path) { + public List getDoubleList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -555,12 +575,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getFloatList(String path) { + public List getFloatList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -590,12 +615,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getLongList(String path) { + public List getLongList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -625,12 +655,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getByteList(String path) { + public List getByteList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -660,12 +695,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getCharacterList(String path) { + public List getCharacterList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) { @@ -697,12 +737,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getShortList(String path) { + public List getShortList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List list = getList(path); + + if (list == null) { + return null; + } + List result = new ArrayList(); for (Object object : list) {