mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 01:27:42 +01:00
Disconnect HTTP Connection after using IP2C
Affects issues: - Possibly fixes #1296, #1291, #1292
This commit is contained in:
parent
bccff17d85
commit
f5809420a5
@ -72,15 +72,20 @@ public class IP2CGeolocator implements Geolocator {
|
||||
}
|
||||
|
||||
public Optional<String> readIPFromURL(String address) throws IOException {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL("http://ip2c.org/" + address).openConnection();
|
||||
connection.setDefaultUseCaches(false);
|
||||
connection.setUseCaches(false);
|
||||
connection.connect();
|
||||
try (
|
||||
InputStream in = connection.getInputStream()
|
||||
) {
|
||||
String answer = readAnswer(in);
|
||||
return resolveIP(answer);
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
connection = (HttpURLConnection) new URL("http://ip2c.org/" + address).openConnection();
|
||||
connection.setDefaultUseCaches(false);
|
||||
connection.setUseCaches(false);
|
||||
connection.connect();
|
||||
try (
|
||||
InputStream in = connection.getInputStream()
|
||||
) {
|
||||
String answer = readAnswer(in);
|
||||
return resolveIP(answer);
|
||||
}
|
||||
} finally {
|
||||
if (connection != null) connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user