From 5d4ad351d6ed02acfe20187b807342185232af18 Mon Sep 17 00:00:00 2001 From: Justus Garbe Date: Fri, 1 Mar 2024 18:26:24 +0100 Subject: [PATCH] Fix no try with resource statements --- .../coley/recaf/services/config/ConfigManager.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/recaf-core/src/main/java/software/coley/recaf/services/config/ConfigManager.java b/recaf-core/src/main/java/software/coley/recaf/services/config/ConfigManager.java index 2b402a0b9..e86fb83c4 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/config/ConfigManager.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/config/ConfigManager.java @@ -74,10 +74,8 @@ private void save() { } } - try { - BufferedWriter writer = Files.newBufferedWriter(containerPath); + try(JsonWriter writer = new JsonWriter(Files.newBufferedWriter(containerPath))) { gson.toJson(json, writer); - writer.close(); } catch (IOException e) { logger.error("Failed to save config container: {}", key, e); } @@ -103,8 +101,7 @@ private void load() { } JsonObject json; - try { - JsonReader reader = new JsonReader(Files.newBufferedReader(containerPath)); + try (JsonReader reader = new JsonReader(Files.newBufferedReader(containerPath))) { json = gson.fromJson(reader, JsonObject.class); } catch (IOException e) { logger.error("Failed to load config container: {}", key, e);