From ef9815d10ef8dcd39aa856ec03bca65ce75cab5a Mon Sep 17 00:00:00 2001 From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:23:06 +0800 Subject: [PATCH] Another correction --- .../java/io/wdsj/asw/bukkit/update/Updater.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java index dd85f6e..0259013 100644 --- a/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java +++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java @@ -63,13 +63,15 @@ protected boolean isDevUpdateAvailable() { connection.setReadTimeout(5000); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { - InputStreamReader reader = new InputStreamReader(connection.getInputStream()); - JsonObject jsonObject = new JsonParser().parse(reader).getAsJsonObject(); - String latestHash = jsonObject.get("sha").getAsString(); - latestVersion = latestHash.substring(0, 7); - currentVersion = PluginVersionTemplate.COMMIT_HASH_SHORT; - isUpdateAvailable = !PluginVersionTemplate.COMMIT_HASH.equals(latestHash); - return isUpdateAvailable; + try (InputStreamReader reader = new InputStreamReader(connection.getInputStream())) { + JsonObject jsonObject = new JsonParser().parse(reader).getAsJsonObject(); + String latestHash = jsonObject.get("sha").getAsString(); + latestVersion = latestHash.substring(0, 7); + currentVersion = PluginVersionTemplate.COMMIT_HASH_SHORT; + isUpdateAvailable = !PluginVersionTemplate.COMMIT_HASH.equals(latestHash); + reader.close(); + return isUpdateAvailable; + } } } catch (Exception ignored) { }