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

Exception when FromRepository tries to delete a message

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3.0
    • Labels:
      None

      Description

      I am trying to get a FromRepository in the air, that will respool messages that were dumped in an error repository earlier.

      This is my configuration:

      <!-- Respool messages that could not be delivered earlier -->
      <mailet match="SubjectStartsWith=Respool-Out" class="FromRepository">
      <repositoryPath> file://../../../../spool/outgoing-undeliverable/
      </repositoryPath>
      <processor> root </processor>
      <delete> true </delete>
      </mailet>

      However, when this mailet is triggered I get the following exception.

      java.lang.ClassCastException
      at org.apache.james.mailrepository.AvalonMailRepository.remove(AvalonMailRepository.java:372)
      at org.apache.james.transport.mailets.FromRepository.service(FromRepository.java:132)
      at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:407)
      at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:451)
      at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:360)
      at java.lang.Thread.run(Unknown Source)

      Messages seem to be respooled but are not deleted.

      Proposed fix: Make AvalonMailRepository.remove(Collection) take Collections of Strings as well as Collections of MailImpl objects.

      Proposed new implementation:

      /**

      • Removes a Collection of mails from the repository
      • @param mails The Collection of <code>MailImpl</code>'s to delete
      • @throws MessagingException
      • @since 2.2.0
        */
        public void remove(Collection mails) throws MessagingException {
        Iterator delList = mails.iterator();
        while (delList.hasNext())
        Unknown macro: { Object next = delList.next(); if (next instanceof MailImpl) { remove( (MailImpl) next); } else if (next instanceof String) { remove( (String) next); } else if (next instanceof Collection) { remove( (Collection) next); } }

        }

      Diff against 2.2.0 release tag:

      Index: AvalonMailRepository.java
      ===================================================================
      — AvalonMailRepository.java (revision 37982)
      +++ AvalonMailRepository.java (working copy)
      @@ -369,7 +369,16 @@
      public void remove(Collection mails) throws MessagingException {
      Iterator delList = mails.iterator();
      while (delList.hasNext()) {

      • remove((MailImpl)delList.next());
        + Object next = delList.next();
        + if (next instanceof MailImpl) { + remove( (MailImpl) next); + }

        + else if (next instanceof String)

        { + remove( (String) next); + }

        + else if (next instanceof Collection)

        { + remove( (Collection) next); + }

        }
        }

      @@ -404,7 +413,7 @@
      *
      */
      public Iterator list() {

      • // Fix ConcurrentModificationException by cloning
        + // Fix ConcurrentModificationException by cloning
        // the keyset before getting an iterator
        final ArrayList clone;
        synchronized(keys) {

        Issue Links

          Activity

          Hide
          hes Hes Siemelink added a comment -

          Oh sorry, I see this is a duplicate of JAMES-317.

          Show
          hes Hes Siemelink added a comment - Oh sorry, I see this is a duplicate of JAMES-317 .
          Hide
          sbrewin@apache.org Steve Brewin added a comment -

          As Hes said.

          Show
          sbrewin@apache.org Steve Brewin added a comment - As Hes said.
          Hide
          bago Stefano Bagnara added a comment -

          Can we mark this as closed?

          Show
          bago Stefano Bagnara added a comment - Can we mark this as closed?
          Hide
          hes.siemelink Hes Siemelink added a comment -

          By all means!

          Show
          hes.siemelink Hes Siemelink added a comment - By all means!
          Hide
          bago Stefano Bagnara added a comment -

          Noel fix to JAMES-317 invalidate this.

          Show
          bago Stefano Bagnara added a comment - Noel fix to JAMES-317 invalidate this.
          Hide
          danny@apache.org Danny Angus added a comment -

          Closing issue fixed in released version.

          Show
          danny@apache.org Danny Angus added a comment - Closing issue fixed in released version.

            People

            • Assignee:
              noel Noel J. Bergman
              Reporter:
              hes Hes Siemelink
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development