diff --git a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java index ed6ee5cc8c1..53143f69533 100644 --- a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java @@ -296,19 +296,21 @@ public void removeMailboxMsg(MailboxMessage mailboxMessage) { // mailboxMessageList while getting called. UserThread.execute(() -> { String uid = mailboxMessage.getUid(); - if (mailboxItemsByUid.containsKey(uid)) { - // We called removeMailboxEntryFromNetwork at processMyMailboxItem, - // but in case we have not been bootstrapped at that moment it did not get removed from the network. - // So to be sure it gets removed we try to remove it now again. - // In case it was removed earlier it will return early anyway inside the p2pDataStorage. - removeMailboxEntryFromNetwork(mailboxItemsByUid.get(uid).getProtectedMailboxStorageEntry()); - - // We will get called the onRemoved handler which triggers removeMailboxItemFromMap as well. - // But as we use the uid from the decrypted data which is not available at onRemoved we need to - // call removeMailboxItemFromMap here. The onRemoved only removes foreign mailBoxMessages. - log.trace("## removeMailboxMsg uid={}", uid); - removeMailboxItemFromLocalStore(uid); + if (!mailboxItemsByUid.containsKey(uid)) { + return; } + + // We called removeMailboxEntryFromNetwork at processMyMailboxItem, + // but in case we have not been bootstrapped at that moment it did not get removed from the network. + // So to be sure it gets removed we try to remove it now again. + // In case it was removed earlier it will return early anyway inside the p2pDataStorage. + removeMailboxEntryFromNetwork(mailboxItemsByUid.get(uid).getProtectedMailboxStorageEntry()); + + // We will get called the onRemoved handler which triggers removeMailboxItemFromMap as well. + // But as we use the uid from the decrypted data which is not available at onRemoved we need to + // call removeMailboxItemFromMap here. The onRemoved only removes foreign mailBoxMessages. + log.trace("## removeMailboxMsg uid={}", uid); + removeMailboxItemFromLocalStore(uid); }); } else { // In case the network was not ready yet we try again later