Prevent duplicate mailbox creation
* Synchronized findOrCreateMailboxOfType Bug: 3291982 Change-Id: I7146458112296aa2b0f4b8f24d0c86f16a8b6626
This commit is contained in:
parent
a7255de196
commit
900021dbee
@ -427,13 +427,18 @@ public class Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for a specific mailbox, creating it if necessary, and return the mailbox id.
|
||||
* This is a blocking operation and should not be called from the UI thread.
|
||||
*
|
||||
* Synchronized so multiple threads can call it (and not risk creating duplicate boxes).
|
||||
*
|
||||
* @param accountId the account id
|
||||
* @param mailboxType the mailbox type (e.g. EmailContent.Mailbox.TYPE_TRASH)
|
||||
* @return the id of the mailbox. The mailbox is created if not existing.
|
||||
* Returns Mailbox.NO_MAILBOX if the accountId or mailboxType are negative.
|
||||
* Does not validate the input in other ways (e.g. does not verify the existence of account).
|
||||
*/
|
||||
public long findOrCreateMailboxOfType(long accountId, int mailboxType) {
|
||||
public synchronized long findOrCreateMailboxOfType(long accountId, int mailboxType) {
|
||||
if (accountId < 0 || mailboxType < 0) {
|
||||
return Mailbox.NO_MAILBOX;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user