don't simply ignore null in message body but try to avoid it
This commit is contained in:
parent
7c608c8862
commit
badc97e280
|
@ -115,7 +115,11 @@ public class PgpDecryptionService {
|
||||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||||
try {
|
try {
|
||||||
os.flush();
|
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);
|
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||||
final HttpConnectionManager manager = mXmppConnectionService.getHttpConnectionManager();
|
final HttpConnectionManager manager = mXmppConnectionService.getHttpConnectionManager();
|
||||||
if (message.trusted()
|
if (message.trusted()
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class Message extends AbstractEntity {
|
||||||
this.conversationUuid = conversationUUid;
|
this.conversationUuid = conversationUUid;
|
||||||
this.counterpart = counterpart;
|
this.counterpart = counterpart;
|
||||||
this.trueCounterpart = trueCounterpart;
|
this.trueCounterpart = trueCounterpart;
|
||||||
this.body = body;
|
this.body = body == null ? "" : body;
|
||||||
this.timeSent = timeSent;
|
this.timeSent = timeSent;
|
||||||
this.encryption = encryption;
|
this.encryption = encryption;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -266,6 +266,9 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBody(String body) {
|
public void setBody(String body) {
|
||||||
|
if (body == null) {
|
||||||
|
throw new Error("You should not set the message body to null");
|
||||||
|
}
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,9 +181,7 @@ public class UIHelper {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String body = message.getBody();
|
String body = message.getBody();
|
||||||
if (body == null) {
|
if (body.length() > 256) {
|
||||||
body = "";
|
|
||||||
} else if (body.length() > 256) {
|
|
||||||
body = body.substring(0,256);
|
body = body.substring(0,256);
|
||||||
}
|
}
|
||||||
if (body.startsWith(Message.ME_COMMAND)) {
|
if (body.startsWith(Message.ME_COMMAND)) {
|
||||||
|
|
Loading…
Reference in a new issue