Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
10.3
-
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.