aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java16
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);
+ }
}
}