Skip to content

Commit 1373911

Browse files
diffblue-assistantdmulloy2
authored andcommitted
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
1 parent 39e0c97 commit 1373911

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

modules/ProtocolLib/src/main/java/com/comphenix/protocol/updater/SpigotUpdater.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ public void run() {
9797
private static final byte[] API_KEY = ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + ID).getBytes(Charsets.UTF_8);
9898

9999
public String getSpigotVersion() throws IOException {
100-
Closer closer = Closer.create();
101-
102-
try {
100+
try (Closer closer = Closer.create()) {
103101
HttpURLConnection con = (HttpURLConnection) new URL(API_URL).openConnection();
104102
con.setDoOutput(true);
105103
con.setRequestMethod(ACTION);
@@ -108,8 +106,6 @@ public String getSpigotVersion() throws IOException {
108106
InputStreamReader isr = closer.register(new InputStreamReader(con.getInputStream()));
109107
BufferedReader br = closer.register(new BufferedReader(isr));
110108
return br.readLine();
111-
} finally {
112-
closer.close();
113109
}
114110
}
115111

0 commit comments

Comments
 (0)