[ https://issues.apache.org/jira/browse/JAMES-2542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16607041#comment-16607041 ]
Abdou Ousmane Issoufou commented on JAMES-2542: ----------------------------------------------- Hello! Thanks for your reply [~BTellier]. I hope you or someone will take a deep look at it and also your locking mecanism because from my point of view there is something weird in the code. You can see that in the following piece of code of the same class, the lock isn't used the same way: {code:java} // AbstractMailRepository.java @Override public void remove(MailKey key) throws MessagingException { if (lock(key)) { try { internalRemove(key); } finally { unlock(key); } } else { throw new MessagingException("Cannot lock " + key + " to remove it"); } } {code} Cheers, Abdou > 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 > Priority: Critical > > 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: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org