aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-05-09 20:35:52 +0200
committerChristian Schneppe <christian@pix-art.de>2017-05-09 20:35:52 +0200
commitf4f71c7287a9ec8250e4b9d93bf58f5231e69597 (patch)
treed5ea75f1bd9bbef6cda1f074e31d5bd1066bf77f /src/main/java/de/pixart/messenger
parent1eec39c87c1f0cb5d092793ba104ffaff2bbf1e2 (diff)
close http download connection after download
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index 722c1dea9..dbbfec861 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -227,6 +227,7 @@ public class HttpDownloadConnection implements Transferable {
}
return Long.parseLong(contentLength, 10);
} catch (IOException e) {
+ Log.d(Config.LOGTAG, "io exception during HEAD " + e.getMessage());
throw e;
} catch (NumberFormatException e) {
throw new IOException();
@@ -269,10 +270,10 @@ public class HttpDownloadConnection implements Transferable {
private void download() throws Exception {
InputStream is = null;
+ HttpURLConnection connection = null;
PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_download_" + message.getUuid());
try {
wakeLock.acquire();
- HttpURLConnection connection;
if (mUseTor) {
connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy());
} else {
@@ -332,10 +333,14 @@ public class HttpDownloadConnection implements Transferable {
throw new FileWriterException();
}
} catch (CancellationException | IOException e) {
+ Log.d(Config.LOGTAG, "http download failed " + e.getMessage());
throw e;
} finally {
FileBackend.close(os);
FileBackend.close(is);
+ if (connection != null) {
+ connection.disconnect();
+ }
wakeLock.release();
}
}