Puts the GSON serialization on main thread. (#1141)

https://github.com/BentoBoxWorld/BentoBox/issues/1128
This commit is contained in:
tastybento 2020-01-16 17:00:23 -08:00 committed by GitHub
parent a9a9a9adee
commit e62240f523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,8 +154,10 @@ public class SQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
plugin.logError("This class is not a DataObject: " + instance.getClass().getName());
return;
}
// This has to be on the main thread to avoid concurrent modification errors
String toStore = getGson().toJson(instance);
// Async
processQueue.add(() -> store(instance.getClass().getName(), getGson().toJson(instance), sqlConfig.getSaveObjectSQL()));
processQueue.add(() -> store(instance.getClass().getName(), toStore, sqlConfig.getSaveObjectSQL()));
}
private void store(String name, String toStore, String sb) {