Use try-with-resources (#158)
Replace try statements that close a resource in the finally block with a try-with-resources statement [1]. This commit was created automatically by Diffblue refactorings (https://www.diffblue.com/). [1] https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
Dieser Commit ist enthalten in:
Ursprung
39e0c974ee
Commit
1373911ca2
@ -97,9 +97,7 @@ public final class SpigotUpdater extends Updater {
|
|||||||
private static final byte[] API_KEY = ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + ID).getBytes(Charsets.UTF_8);
|
private static final byte[] API_KEY = ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + ID).getBytes(Charsets.UTF_8);
|
||||||
|
|
||||||
public String getSpigotVersion() throws IOException {
|
public String getSpigotVersion() throws IOException {
|
||||||
Closer closer = Closer.create();
|
try (Closer closer = Closer.create()) {
|
||||||
|
|
||||||
try {
|
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL(API_URL).openConnection();
|
HttpURLConnection con = (HttpURLConnection) new URL(API_URL).openConnection();
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.setRequestMethod(ACTION);
|
con.setRequestMethod(ACTION);
|
||||||
@ -108,8 +106,6 @@ public final class SpigotUpdater extends Updater {
|
|||||||
InputStreamReader isr = closer.register(new InputStreamReader(con.getInputStream()));
|
InputStreamReader isr = closer.register(new InputStreamReader(con.getInputStream()));
|
||||||
BufferedReader br = closer.register(new BufferedReader(isr));
|
BufferedReader br = closer.register(new BufferedReader(isr));
|
||||||
return br.readLine();
|
return br.readLine();
|
||||||
} finally {
|
|
||||||
closer.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren