From fa36d64a7424e8a42691ddd702794ec0b6b25bbc Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Sun, 24 Sep 2023 09:13:32 -0400 Subject: [PATCH] FileSaver close FileReader (#252) * Update FileSaver.java * Update FileSaver.java --- .../java/de/florianmichael/viafabricplus/util/FileSaver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/util/FileSaver.java b/src/main/java/de/florianmichael/viafabricplus/util/FileSaver.java index 11618684..ec3fd62e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/util/FileSaver.java +++ b/src/main/java/de/florianmichael/viafabricplus/util/FileSaver.java @@ -43,8 +43,8 @@ public abstract class FileSaver { public void init() { if (file.exists()) { JsonObject parentNode = null; - try { - parentNode = ViaFabricPlus.GSON.fromJson(new FileReader(file), JsonObject.class).getAsJsonObject(); + try (final FileReader fr = new FileReader(file)) { + parentNode = ViaFabricPlus.GSON.fromJson(fr, JsonObject.class); } catch (Exception e) { e.printStackTrace(); }