mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-09 09:57:40 +01:00
Rewrote JSON object loading to avoid throwing exception
Related to 68f90edb2f
This commit is contained in:
parent
ead0b02454
commit
52d0544726
@ -58,10 +58,12 @@ public class JSONDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
||||
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.");
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.bentobox.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
Loading…
Reference in New Issue
Block a user