File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
api/src/main/java/me/tofaa/entitylib/utils Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,19 @@ private PEVersion getLatestVersion() throws IOException {
5757 URL url = new URL ("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest" );
5858 URLConnection connection = url .openConnection ();
5959 connection .addRequestProperty ("User-Agent" , "Mozilla/5.0" );
60- InputStreamReader isr = new InputStreamReader (connection .getInputStream ());
61- BufferedReader reader = new BufferedReader (isr );
62- String response = reader .readLine ();
63- JsonObject json = AdventureSerializer .getGsonSerializer ().serializer ().fromJson (response , JsonObject .class );
6460
65- reader .close ();
66- isr .close ();
61+ try (
62+ InputStreamReader isr = new InputStreamReader (connection .getInputStream ());
63+ BufferedReader reader = new BufferedReader (isr )
64+ ) {
65+ String response = reader .readLine ();
66+ JsonObject json = AdventureSerializer .getGsonSerializer ().serializer ().fromJson (response , JsonObject .class );
6767
68- if (json .has ("tag_name" )) {
69- return PEVersion .fromString (json .get ("tag_name" ).getAsString ().replaceFirst ("^[vV]" , "" ));
68+ if (json .has ("tag_name" )) {
69+ return PEVersion .fromString (json .get ("tag_name" ).getAsString ().replaceFirst ("^[vV]" , "" ));
70+ }
71+ throw new IOException ("Could not find name attribute in github api fetch" );
7072 }
71- throw new IOException ("Could not find name attribute in github api fetch" );
7273 }
7374
7475 @ Deprecated
You can’t perform that action at this time.
0 commit comments