You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2020/02/07 07:04:11 UTC
[kylin] 11/14: KYLIN-4309 Fixed bug that failed to send to one
mailbox will caused other mailboxes have no chance to send
This is an automated email from the ASF dual-hosted git repository.
nic pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 786728eb8710145916f100dfa4e8b7b60e4e649f
Author: weibin0516 <co...@126.com>
AuthorDate: Fri Dec 20 13:22:31 2019 +0800
KYLIN-4309 Fixed bug that failed to send to one mailbox will caused other mailboxes have no chance to send
---
.../org/apache/kylin/common/util/MailService.java | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
index 44e1d9c..b68c78d 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.List;
import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.kylin.common.KylinConfig;
import org.slf4j.LoggerFactory;
@@ -100,12 +99,23 @@ public class MailService {
email.setAuthentication(username, password);
}
- //email.setDebug(true);
- try {
- for (String receiver : receivers) {
+ for (String receiver : receivers) {
+ try {
email.addTo(receiver);
+ } catch (Exception e) {
+ logger.error("add " + receiver + " to send to mailbox list failed, " +
+ "this will not affect sending to the valid mailbox", e);
}
+ }
+ // List of valid recipients is empty
+ if (email.getToAddresses().isEmpty()) {
+ logger.error("No valid send to mailbox, please check");
+ return false;
+ }
+
+ // List of valid recipients is not empty
+ try {
email.setFrom(sender);
email.setSubject(subject);
email.setCharset("UTF-8");
@@ -117,11 +127,10 @@ public class MailService {
email.send();
email.getMailSession();
- } catch (EmailException e) {
+ return true;
+ } catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
return false;
}
-
- return true;
}
}