}
//Call the matcher and find what recipients match
Collection recipients = null;
Matcher matcher = (Matcher) matchers.get(i);
StringBuffer logMessageBuffer = null;
if (getLogger().isDebugEnabled()) {
logMessageBuffer =
new StringBuffer(128)
.append("Checking ")
.append(mail.getName())
.append(" with ")
.append(matcher);
getLogger().debug(logMessageBuffer.toString());
}
try {
recipients = matcher.match(mail);
if (recipients == null) {
//In case the matcher returned null, create an empty Collection
recipients = new ArrayList(0);
} else if (recipients != mail.getRecipients()) {
//Make sure all the objects are MailAddress objects
verifyMailAddresses(recipients);
}
} catch (MessagingException me) {
// look in the matcher's mailet's init attributes
MailetConfig mailetConfig = ((Mailet) mailets.get(i)).getMailetConfig();
String onMatchException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMatchException");
if (onMatchException == null) {
onMatchException = Mail.ERROR;
} else {
onMatchException = onMatchException.trim().toLowerCase(Locale.US);
}
if (onMatchException.compareTo("nomatch") == 0) {
//In case the matcher returned null, create an empty Collection
recipients = new ArrayList(0);
} else if (onMatchException.compareTo("matchall") == 0) {
recipients = mail.getRecipients();
// no need to verify addresses
} else {
handleException(me, mail, matcher.getMatcherConfig().getMatcherName(), onMatchException);
}
}
// Split the recipients into two pools. notRecipients will contain the
// recipients on the message that the matcher did not return.