Abdou Ousmane Issoufou created JAMES-2542:
---------------------------------------------

             Summary: AbstractMailRepository locking/unlocking issue when 
storing
                 Key: JAMES-2542
                 URL: https://issues.apache.org/jira/browse/JAMES-2542
             Project: James Server
          Issue Type: Bug
          Components: MailStore & MailRepository
    Affects Versions: master
            Reporter: Abdou Ousmane Issoufou


In AbstractMailRepository.java#store(Mail mc) there is an issue in the finally 
block because the condition of the if statement is !waslocked instead of 
waslocked. The comment also needs to be updated to "If it was locked, we need 
to unlock now"

 
{code:java}
// AbstractMailRepository.java
@Override
public MailKey store(Mail mc) throws MessagingException {
boolean wasLocked = true;
MailKey key = MailKey.forMail(mc);
try {
synchronized (this) {
wasLocked = lock.isLocked(key);
if (!wasLocked) {
// If it wasn't locked, we want a lock during the store
lock(key);
}
}
internalStore(mc);
return key;
} catch (MessagingException e) {
LOGGER.error("Exception caught while storing mail {}", key, e);
throw e;
} catch (Exception e) {
LOGGER.error("Exception caught while storing mail {}", key, e);
throw new MessagingException("Exception caught while storing mail " + key, e);
} finally {
if (!wasLocked) {
// If it wasn't locked, we need to unlock now
unlock(key);
synchronized (this) {
notify();
}
}
}
}
{code}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to