diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-08-01 12:06:46 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-08-01 12:06:46 +0200 |
commit | ea1a9d898ee529fc94e0d0accf386cadb50e1b3e (patch) | |
tree | acb4d25e5800a32850b2d775feb9bebeaa8b557b /src | |
parent | 68f8d0ac8524417ae44cfac4286397bcdf6c4045 (diff) |
sync around Conversation.getLatestMessage()
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Conversation.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 0ebd31b71..9646a3990 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -484,13 +484,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); + } } } |