Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-2542

AbstractMailRepository locking/unlocking issue when storing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • master
    • None
    • None
    • Important

    Description

      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"

       

      // 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();
      }
      }
      }
      }
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            abdouoi Abdou Ousmane Issoufou
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: