aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-09-18 22:15:02 +0200
committerChristian Schneppe <christian@pix-art.de>2016-09-23 21:46:02 +0200
commitcccd15e4dc1ba769727fdfeb3359c2307f3e8ac6 (patch)
treea97e40c81cd6021385fb75b7c7e2c6c84776cbae /src
parent414febeb94b73733d660bed3993f0cde06360a42 (diff)
don't simply ignore null in message body but try to avoid it
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java6
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java6
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java4
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)) {