aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-01 12:06:46 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-01 12:06:46 +0200
commitea1a9d898ee529fc94e0d0accf386cadb50e1b3e (patch)
treeacb4d25e5800a32850b2d775feb9bebeaa8b557b /src
parent68f8d0ac8524417ae44cfac4286397bcdf6c4045 (diff)
sync around Conversation.getLatestMessage()
Diffstat (limited to 'src')
-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);
+ }
}
}