Make new methods for undoing deletions synchronized.

This commit is contained in:
leopoldsedev
2020-02-15 17:26:08 +01:00
committed by Jannis Mattheis
parent dc9426bbae
commit 0ebeeec35e
2 changed files with 5 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ public class MessageFacade {
return state.getLastReceivedMessage(); return state.getLastReceivedMessage();
} }
public void deleteLocal(Message message) { public synchronized void deleteLocal(Message message) {
this.state.removeMessage(message); this.state.removeMessage(message);
// If there is already a deletion pending, that one should be executed before scheduling the // If there is already a deletion pending, that one should be executed before scheduling the
// next deletion. // next deletion.
@@ -70,12 +70,12 @@ public class MessageFacade {
messagePendingDeletion = message; messagePendingDeletion = message;
} }
public void commitDelete() { public synchronized void commitDelete() {
this.requester.asyncRemoveMessage(messagePendingDeletion); this.requester.asyncRemoveMessage(messagePendingDeletion);
messagePendingDeletion = null; messagePendingDeletion = null;
} }
public PositionPair undoDeleteLocal() { public synchronized PositionPair undoDeleteLocal() {
messagePendingDeletion = null; messagePendingDeletion = null;
return this.state.undoLastRemoveMessage(); return this.state.undoLastRemoveMessage();
} }

View File

@@ -66,7 +66,7 @@ class MessageStateHolder {
return lastReceivedMessage; return lastReceivedMessage;
} }
void removeMessage(Message message) { synchronized void removeMessage(Message message) {
MessageState allMessages = state(MessageState.ALL_MESSAGES); MessageState allMessages = state(MessageState.ALL_MESSAGES);
MessageState appMessages = state(message.getAppid()); MessageState appMessages = state(message.getAppid());
@@ -85,7 +85,7 @@ class MessageStateHolder {
lastRemovedMessage = message; lastRemovedMessage = message;
} }
PositionPair undoLastRemoveMessage() { synchronized PositionPair undoLastRemoveMessage() {
PositionPair result = null; PositionPair result = null;
if (lastRemovedMessage != null) { if (lastRemovedMessage != null) {