diff options
Diffstat (limited to 'src')
3 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java index 02c094b71..b3f2e64da 100644 --- a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java +++ b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java @@ -115,7 +115,11 @@ public class PgpDecryptionService { case OpenPgpApi.RESULT_CODE_SUCCESS: try { os.flush(); - message.setBody(os.toString()); + final String body = os.toString(); + if (body == null) { + throw new IOException("body was null"); + } + message.setBody(body); message.setEncryption(Message.ENCRYPTION_DECRYPTED); final HttpConnectionManager manager = mXmppConnectionService.getHttpConnectionManager(); if (message.trusted() diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index 20a7ea002..26847b37a 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -124,7 +124,7 @@ public class Message extends AbstractEntity { this.conversationUuid = conversationUUid; this.counterpart = counterpart; this.trueCounterpart = trueCounterpart; - this.body = body; + this.body = body == null ? "" : body; this.timeSent = timeSent; this.encryption = encryption; this.status = status; @@ -266,7 +266,9 @@ public class Message extends AbstractEntity { } public void setBody(String body) { - this.body = body; + if (body == null) { + throw new Error("You should not set the message body to null"); + } } public long getTimeSent() { diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index 7e2d46018..fbd41fa0a 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -180,9 +180,7 @@ public class UIHelper { } } else { String body = message.getBody(); - if (body == null) { - body = ""; - } else if (body.length() > 256) { + if (body.length() > 256) { body = body.substring(0, 256); } if (body.startsWith(Message.ME_COMMAND)) { |