Close reader objects

This commit is contained in:
HexedHero 2024-05-10 02:37:43 +01:00
parent ffc4014e58
commit 6d78a37805

View File

@ -39,7 +39,9 @@ public class SpigotUpdater {
*/
public String getLatestVersion() throws Exception {
final URLConnection con = checkURL.openConnection();
this.newVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
this.newVersion = reader.readLine();
}
return newVersion;
}
@ -60,7 +62,9 @@ public class SpigotUpdater {
*/
public boolean checkForUpdates() throws Exception {
final URLConnection con = checkURL.openConnection();
this.newVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
this.newVersion = reader.readLine();
}
return !plugin.getDescription().getVersion().equals(newVersion);
}
}