[FIX] Backport 'Reset null config'

This commit is contained in:
Gravita 2023-09-20 19:57:03 +07:00
parent e640219688
commit 098eff91e6

View file

@ -41,7 +41,13 @@ default String toJsonString() {
default void loadConfig(Gson gson, Path configPath) throws IOException { default void loadConfig(Gson gson, Path configPath) throws IOException {
if (generateConfigIfNotExists(configPath)) return; if (generateConfigIfNotExists(configPath)) return;
try (BufferedReader reader = IOHelper.newReader(configPath)) { try (BufferedReader reader = IOHelper.newReader(configPath)) {
setConfig(gson.fromJson(reader, getType())); T value = gson.fromJson(reader, getType());
if(value == null) {
LogHelper.warning("Config %s is null", configPath);
resetConfig(configPath);
return;
}
setConfig(value);
} catch (Exception e) { } catch (Exception e) {
LogHelper.error(e); LogHelper.error(e);
resetConfig(configPath); resetConfig(configPath);