aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-09-15 22:49:43 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-09-15 22:49:43 +0200
commitb5719fd747a9a6d9757eccb0f20c22c2daaa9928 (patch)
tree4d542093d2fa2abc015a1c2bfa27089ecd9502cb /src/main/java/eu/siacs/conversations
parent999d65c1876c2ec23e2202563fa81ca58c0ba430 (diff)
work around a NPE caused by arace condition in the http upload
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
index 2e5458423..38e25e7af 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
@@ -70,11 +70,14 @@ public class HttpUploadConnection implements Transferable {
@Override
public long getFileSize() {
- return this.file.getExpectedSize();
+ return file == null ? 0 : file.getExpectedSize();
}
@Override
public int getProgress() {
+ if (file == null) {
+ return 0;
+ }
return (int) ((((double) transmitted) / file.getExpectedSize()) * 100);
}
@@ -92,8 +95,6 @@ public class HttpUploadConnection implements Transferable {
public void init(Message message, boolean delay) {
this.message = message;
- message.setTransferable(this);
- mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
this.account = message.getConversation().getAccount();
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
this.mime = this.file.getMimeType();
@@ -139,6 +140,8 @@ public class HttpUploadConnection implements Transferable {
}
}
});
+ message.setTransferable(this);
+ mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
}
private class FileUploader implements Runnable {