public long nextUid(MailboxSession session, Mailbox mailbox) throws MailboxException {
if (client.isStarted()) {
DistributedAtomicLong uid = new DistributedAtomicLong(client, pathForMailbox(mailbox), retryPolicy);
AtomicValue<Long> value = null;
try {
uid.increment();
value = uid.get();
} catch (Exception e) {
throw new MailboxException("Exception incrementing UID for session " + session, e);
} finally {
if (value != null && value.succeeded()) {