add retMap null check for AlertSender (#1796)
* fix bug: zk hasTask method NPE * add retMap null check for AlertSender
This commit is contained in:
parent
b9ac6d66f1
commit
1a86e7bae7
|
|
@ -31,6 +31,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -72,9 +73,7 @@ public class AlertSender{
|
|||
String receivers = alert.getReceivers();
|
||||
if (StringUtils.isNotEmpty(receivers)){
|
||||
String[] splits = receivers.split(",");
|
||||
for (String receiver : splits){
|
||||
receviersList.add(receiver);
|
||||
}
|
||||
receviersList.addAll(Arrays.asList(splits));
|
||||
}
|
||||
|
||||
// copy list
|
||||
|
|
@ -86,9 +85,7 @@ public class AlertSender{
|
|||
|
||||
if (StringUtils.isNotEmpty(receiversCc)){
|
||||
String[] splits = receiversCc.split(",");
|
||||
for (String receiverCc : splits){
|
||||
receviersCcList.add(receiverCc);
|
||||
}
|
||||
receviersCcList.addAll(Arrays.asList(splits));
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(receviersList) && CollectionUtils.isEmpty(receviersCcList)) {
|
||||
|
|
@ -106,7 +103,13 @@ public class AlertSender{
|
|||
alert.setInfo(retMaps);
|
||||
}
|
||||
|
||||
boolean flag = Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)));
|
||||
//send flag
|
||||
boolean flag = false;
|
||||
|
||||
if (null != retMaps) {
|
||||
flag = Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)));
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
alertDao.updateAlert(AlertStatus.EXECUTION_SUCCESS, "execution success", alert.getId());
|
||||
logger.info("alert send success");
|
||||
|
|
@ -121,8 +124,10 @@ public class AlertSender{
|
|||
}
|
||||
|
||||
} else {
|
||||
alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, String.valueOf(retMaps.get(Constants.MESSAGE)), alert.getId());
|
||||
logger.info("alert send error : {}", String.valueOf(retMaps.get(Constants.MESSAGE)));
|
||||
if (null != retMaps) {
|
||||
alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, String.valueOf(retMaps.get(Constants.MESSAGE)), alert.getId());
|
||||
logger.info("alert send error : {}", retMaps.get(Constants.MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
|
|
@ -47,7 +48,7 @@ public class ExcelUtils {
|
|||
//The JSONUtils.toList has been try catch ex
|
||||
itemsList = JSONUtils.toList(content, LinkedHashMap.class);
|
||||
|
||||
if (itemsList == null || itemsList.size() == 0){
|
||||
if (CollectionUtils.isEmpty(itemsList)){
|
||||
logger.error("itemsList is null");
|
||||
throw new RuntimeException("itemsList is null");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
|||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.*;
|
||||
|
|
@ -33,7 +32,6 @@ import java.io.*;
|
|||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* mail utils
|
||||
*/
|
||||
|
|
@ -320,12 +318,12 @@ public class MailUtils {
|
|||
public static void deleteFile(File file){
|
||||
if(file.exists()){
|
||||
if(file.delete()){
|
||||
logger.info("delete success:"+file.getAbsolutePath()+file.getName());
|
||||
logger.info("delete success: {}",file.getAbsolutePath() + file.getName());
|
||||
}else{
|
||||
logger.info("delete fail"+file.getAbsolutePath()+file.getName());
|
||||
logger.info("delete fail: {}", file.getAbsolutePath() + file.getName());
|
||||
}
|
||||
}else{
|
||||
logger.info("file not exists:"+file.getAbsolutePath()+file.getName());
|
||||
logger.info("file not exists: {}", file.getAbsolutePath() + file.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue