File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/main/java/eu/decentsoftware/holograms/api/utils/items Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 19
19
import java .io .InputStreamReader ;
20
20
import java .lang .reflect .Field ;
21
21
import java .lang .reflect .Method ;
22
+ import java .net .HttpURLConnection ;
22
23
import java .net .URL ;
24
+ import java .net .URLConnection ;
23
25
import java .util .Collection ;
24
26
import java .util .UUID ;
25
27
@@ -235,9 +237,12 @@ public static String getPlayerUUID(String playerName) {
235
237
@ NonNull
236
238
private static String readUrl (String urlString ) throws Exception {
237
239
BufferedReader reader = null ;
240
+ URLConnection connection = null ;
238
241
try {
239
- URL url = new URL (urlString );
240
- reader = new BufferedReader (new InputStreamReader (url .openStream ()));
242
+ connection = new URL (urlString ).openConnection ();
243
+ connection .setConnectTimeout (50 );
244
+ connection .setReadTimeout (50 );
245
+ reader = new BufferedReader (new InputStreamReader (connection .getInputStream ()));
241
246
StringBuilder builder = new StringBuilder ();
242
247
int read ;
243
248
char [] chars = new char [1024 ];
@@ -246,6 +251,9 @@ private static String readUrl(String urlString) throws Exception {
246
251
}
247
252
return builder .toString ();
248
253
} finally {
254
+ if (connection instanceof HttpURLConnection ) {
255
+ ((HttpURLConnection ) connection ).disconnect ();
256
+ }
249
257
if (reader != null ) {
250
258
reader .close ();
251
259
}
You can’t perform that action at this time.
0 commit comments