提交 329891f8 编写于 作者: V vsizikov

Fixed a bug where empty list of recipients of build notification messages...

Fixed a bug where empty list of recipients of build notification messages causes NPE in Mailer component.

Submitted by:  Vladimir Sizikov
Reviewed by:   Kohsuke

CVS: ----------------------------------------------------------------------
CVS: Issue number:
CVS:   If this change addresses one or more issues,
CVS:   then enter the issue number(s) here.
CVS: Obtained from:
CVS:   If this change has been taken from another system,
CVS:   then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS:   If this code has been contributed to the project by someone else; i.e.,
CVS:   they sent us a patch or a set of diffs, then include their name/email
CVS:   address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS:   If we are doing pre-commit code reviews and someone else has
CVS:   reviewed your changes, include their name(s) here.
CVS:   If you have not had it reviewed then delete this line.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1124 71c3de6d-444a-0410-be80-ed276b4c234a
上级 dbda5305
......@@ -75,11 +75,17 @@ public class Mailer extends Publisher {
try {
MimeMessage mail = getMail(build);
if(mail!=null) {
StringBuffer buf = new StringBuffer("Sending e-mails to ");
for (Address a : mail.getAllRecipients())
buf.append(' ').append(a);
listener.getLogger().println(buf);
Transport.send(mail);
Address[] allRecipients = mail.getAllRecipients();
if(allRecipients!=null) {
StringBuffer buf = new StringBuffer("Sending e-mails to ");
for (Address a : allRecipients)
buf.append(' ').append(a);
listener.getLogger().println(buf);
Transport.send(mail);
} else {
listener.getLogger().println("An attempt to send an e-mail"
+ " to empty list of recipients, ignored.");
}
}
} catch (MessagingException e) {
e.printStackTrace( listener.error(e.getMessage()) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册