Removed lazy initialization of gson
import com.google.gson.stream.JsonReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.terasology.config.flexible.settings.Setting;
import org.terasology.engine.SimpleUri;
import org.terasology.engine.TerasologyConstants;
import org.terasology.engine.paths.PathManager;
public class FlexibleConfigManagerImpl implements FlexibleConfigManager {
private static final Logger logger = LoggerFactory.getLogger(FlexibleConfigManager.class);
- private static Gson gson;
+ private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
private Map<SimpleUri, FlexibleConfig> flexibleConfigs = Maps.newHashMap();
@@ -120,7 +121,7 @@ public void save() {
}
}
- getGson().toJson(jsonObject, writer);
+ gson.toJson(jsonObject, writer);
} catch (IOException e) {
logger.error("Failed to save config", e);
}
@@ -140,12 +141,4 @@ private Path getPathForFlexibleConfig(SimpleUri flexibleConfigUri) {
ensureDirectoryExists(filePath);
return filePath;
}
-
- private Gson getGson() {
- if (gson == null) {
- gson = new GsonBuilder().setPrettyPrinting().create();
- }
-
- return gson;
- }
}
