sync around Conversation.getLatestMessage()

This commit is contained in:
Daniel Gultsch 2017-07-11 23:09:51 +02:00
parent 4d1b6d4404
commit 8de81e0bc8
1 changed files with 9 additions and 7 deletions

View File

@ -470,13 +470,15 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public Message getLatestMessage() {
if (this.messages.size() == 0) {
Message message = new Message(this, "", Message.ENCRYPTION_NONE);
message.setType(Message.TYPE_STATUS);
message.setTime(Math.max(getCreated(),getLastClearHistory().getTimestamp()));
return message;
} else {
return this.messages.get(this.messages.size() - 1);
synchronized (this.messages) {
if (this.messages.size() == 0) {
Message message = new Message(this, "", Message.ENCRYPTION_NONE);
message.setType(Message.TYPE_STATUS);
message.setTime(Math.max(getCreated(), getLastClearHistory().getTimestamp()));
return message;
} else {
return this.messages.get(this.messages.size() - 1);
}
}
}