mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-03 23:17:41 +01:00
Added null checking protection.
This may help if a database is becoming corrupted.
This commit is contained in:
parent
9b44dbb113
commit
5b6bd72370
@ -10,10 +10,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.database.json.AbstractJSONDatabaseHandler;
|
|
||||||
import world.bentobox.bentobox.database.DatabaseConnector;
|
import world.bentobox.bentobox.database.DatabaseConnector;
|
||||||
|
import world.bentobox.bentobox.database.json.AbstractJSONDatabaseHandler;
|
||||||
import world.bentobox.bentobox.database.objects.DataObject;
|
import world.bentobox.bentobox.database.objects.DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +73,17 @@ public class MySQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
// Load all the results
|
// Load all the results
|
||||||
Gson gson = getGson();
|
Gson gson = getGson();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
list.add(gson.fromJson(resultSet.getString("json"), dataObject));
|
String json = resultSet.getString("json");
|
||||||
|
if (json != null) {
|
||||||
|
try {
|
||||||
|
T gsonResult = gson.fromJson(json, dataObject);
|
||||||
|
if (gsonResult != null) {
|
||||||
|
list.add(gsonResult);
|
||||||
|
}
|
||||||
|
} catch (JsonSyntaxException ex) {
|
||||||
|
plugin.logError("Could not load object " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user