Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15213

Incompatibility in the Mail API between the factory produced and component accepted types

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 10.3
    • Mail
    • None
    • Unknown

    Description

      Some (4) MimeMessageFactories in the Mail module extend the

      abstract class AbstractIteratorMimeMessageFactory extends AbstractMimeMessageFactory<Iterator<MimeMessage>>

      As a result, their return type is Iterator<MimeMessage> which is incompatible with the type accepted by MailSender#sendAsynchronously(Iterable<? extends MimeMessage> messages...).

      In order to be able to use the Iterator<MimeMessage> result of the factory, one must do one of the following:

      • >= Java8: () -> messages
      • < Java 8: Create a wrapper class that returns Iterable<? extends MimeMessage> which simply wraps and re-produces the iterator
      • Same as above, but use instead org.apache.commons.collections4.iterators.IteratorIterable and do new IteratorIterable(messages); (suggested by tmortagne)

      The API should be consistent and use one of the 2 options (iterator or iterable) and not force the client to work around it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            enygma Eduard Moraru
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: