diff --git a/src/main/java/world/bentobox/bentobox/database/json/JSONDatabaseHandler.java b/src/main/java/world/bentobox/bentobox/database/json/JSONDatabaseHandler.java index 9ec4dfc73..3b8cb8a15 100644 --- a/src/main/java/world/bentobox/bentobox/database/json/JSONDatabaseHandler.java +++ b/src/main/java/world/bentobox/bentobox/database/json/JSONDatabaseHandler.java @@ -58,10 +58,12 @@ public class JSONDatabaseHandler extends AbstractJSONDatabaseHandler { for (File file: Objects.requireNonNull(tableFolder.listFiles((dir, name) -> name.toLowerCase(Locale.ENGLISH).endsWith(JSON)))) { try (FileReader reader = new FileReader(file)){ T object = getGson().fromJson(reader, dataObject); - if (object == null) { - throw new IOException("JSON file created a null object: " + file.getPath()); + if (object != null) { + list.add(object); + } else { + plugin.logError("JSON file created a null object: " + file.getPath()); + reader.close(); } - list.add(object); } catch (FileNotFoundException e) { plugin.logError("Could not load file '" + file.getName() + "': File not found."); diff --git a/src/test/java/world/bentobox/bentobox/database/DatabaseTest.java b/src/test/java/world/bentobox/bentobox/database/DatabaseTest.java index 2342bc6f2..fb74ac9f5 100644 --- a/src/test/java/world/bentobox/bentobox/database/DatabaseTest.java +++ b/src/test/java/world/bentobox/bentobox/database/DatabaseTest.java @@ -1,6 +1,3 @@ -/** - * - */ package world.bentobox.bentobox.database; import static org.junit.Assert.assertEquals;