forked from j62/ctbrec
1
0
Fork 0

Fix resource leak in update check

This commit is contained in:
0xboobface 2019-12-31 12:10:44 +01:00
parent f312d5ed58
commit 627eb585c8
1 changed files with 3 additions and 6 deletions

View File

@ -360,10 +360,9 @@ public class CamrecApplication extends Application {
private void checkForUpdates() {
Thread updateCheck = new Thread(() -> {
try {
String url = "https://pastebin.com/raw/mUxtKzyB";
Request request = new Request.Builder().url(url).build();
Response response = httpClient.execute(request);
try (Response response = httpClient.execute(request)) {
if (response.isSuccessful()) {
Moshi moshi = new Moshi.Builder().build();
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);
}
}
response.close();
} catch (IOException e) {
LOG.warn("Update check failed {}", e.getMessage());
}
});
updateCheck.setName("Update Check");
updateCheck.setDaemon(true);