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

Exception when FromRepository tries to delete a message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.2.0
    • 2.3.0
    • 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) {

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: