forked from j62/ctbrec
Fix resource leak in update check
This commit is contained in:
parent
f312d5ed58
commit
627eb585c8
|
@ -360,10 +360,9 @@ public class CamrecApplication extends Application {
|
||||||
|
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
Thread updateCheck = new Thread(() -> {
|
Thread updateCheck = new Thread(() -> {
|
||||||
try {
|
String url = "https://pastebin.com/raw/mUxtKzyB";
|
||||||
String url = "https://pastebin.com/raw/mUxtKzyB";
|
Request request = new Request.Builder().url(url).build();
|
||||||
Request request = new Request.Builder().url(url).build();
|
try (Response response = httpClient.execute(request)) {
|
||||||
Response response = httpClient.execute(request);
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
Moshi moshi = new Moshi.Builder().build();
|
Moshi moshi = new Moshi.Builder().build();
|
||||||
Type type = Types.newParameterizedType(List.class, Release.class);
|
Type type = Types.newParameterizedType(List.class, Release.class);
|
||||||
|
@ -379,11 +378,9 @@ public class CamrecApplication extends Application {
|
||||||
LOG.debug("ctbrec is up-to-date {}", ctbrecVersion);
|
LOG.debug("ctbrec is up-to-date {}", ctbrecVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.warn("Update check failed {}", e.getMessage());
|
LOG.warn("Update check failed {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
updateCheck.setName("Update Check");
|
updateCheck.setName("Update Check");
|
||||||
updateCheck.setDaemon(true);
|
updateCheck.setDaemon(true);
|
||||||
|
|
Loading…
Reference in New Issue