if (mailboxId <= 0) throw MailServiceException.NO_SUCH_MBOX(mailboxId);  synchronized (sMailboxCache) { Object obj = sMailboxCache.get(mailboxId); if (obj instanceof Mailbox) return (Mailbox) obj; else if (obj instanceof MailboxLock) { MailboxLock lock = (MailboxLock) obj; if (lock.owner != Thread.currentThread()) throw MailServiceException.MAINTENANCE(mailboxId); if (lock.mailbox != null) return lock.mailbox; }   Connection conn = null; try { conn = DbPool.getConnection(); MailboxData mdata = DbMailbox.getMailboxStats(conn, mailboxId); if (mdata == null) throw MailServiceException.NO_SUCH_MBOX(mailboxId); Mailbox mailbox = new Mailbox(mdata); if (obj instanceof MailboxLock) ((MailboxLock) obj).mailbox = mailbox; else sMailboxCache.put(mailboxId, mailbox);  return mailbox; } finally { if (conn != null) DbPool.quietClose(conn); } }
return getMailboxById(mailboxId, false);
    public static Mailbox getMailboxById(int mailboxId) throws ServiceException {        if (mailboxId <= 0)            throw MailServiceException.NO_SUCH_MBOX(mailboxId);        synchronized (sMailboxCache) {            Object obj = sMailboxCache.get(mailboxId);            if (obj instanceof Mailbox)                return (Mailbox) obj;            else if (obj instanceof MailboxLock) {                MailboxLock lock = (MailboxLock) obj;                if (lock.owner != Thread.currentThread())                    throw MailServiceException.MAINTENANCE(mailboxId);                if (lock.mailbox != null)                    return lock.mailbox;            }            // fetch the Mailbox data from the database            Connection conn = null;            try {                conn = DbPool.getConnection();                MailboxData mdata = DbMailbox.getMailboxStats(conn, mailboxId);                if (mdata == null)                    throw MailServiceException.NO_SUCH_MBOX(mailboxId);                Mailbox mailbox = new Mailbox(mdata);                if (obj instanceof MailboxLock)                    ((MailboxLock) obj).mailbox = mailbox;                else                    sMailboxCache.put(mailboxId, mailbox);                // DbMailItem.writeCheckpoint(mailbox);                return mailbox;            } finally {                if (conn != null)                    DbPool.quietClose(conn);            }        }    }