提交 c522ea7e 编写于 作者: J Jave-Chen 提交者: dailidong

Fix bug: NullPointerException etc. (#1721)

* #1720 Fix bug: NullPointerException etc.

* fix code smell

* Update DateInterval.java

refactor equals method
Co-authored-by: Ndailidong <dailidong66@gmail.com>
上级 abe80fc5
...@@ -101,6 +101,11 @@ public class AlertSender{ ...@@ -101,6 +101,11 @@ public class AlertSender{
}else if (alert.getAlertType() == AlertType.SMS){ }else if (alert.getAlertType() == AlertType.SMS){
retMaps = emailManager.send(getReciversForSMS(users), alert.getTitle(), alert.getContent(),alert.getShowType()); retMaps = emailManager.send(getReciversForSMS(users), alert.getTitle(), alert.getContent(),alert.getShowType());
alert.setInfo(retMaps); alert.setInfo(retMaps);
} else {
logger.error("AlertType is not defined. code: {}, descp: {}",
alert.getAlertType().getCode(),
alert.getAlertType().getDescp());
return;
} }
//send flag //send flag
......
...@@ -499,6 +499,10 @@ public class ExecutorService extends BaseService{ ...@@ -499,6 +499,10 @@ public class ExecutorService extends BaseService{
} }
} }
if ( start == null || end == null) {
return 0;
}
if(commandType == CommandType.COMPLEMENT_DATA){ if(commandType == CommandType.COMPLEMENT_DATA){
runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode;
if(null != start && null != end && start.before(end)){ if(null != start && null != end && start.before(end)){
...@@ -546,9 +550,7 @@ public class ExecutorService extends BaseService{ ...@@ -546,9 +550,7 @@ public class ExecutorService extends BaseService{
}else{ }else{
command.setCommandParam(JSONUtils.toJson(cmdParam)); command.setCommandParam(JSONUtils.toJson(cmdParam));
return processDao.createCommand(command); return processDao.createCommand(command);
} }
return 0;
} }
/** /**
......
...@@ -35,13 +35,12 @@ public class DateInterval { ...@@ -35,13 +35,12 @@ public class DateInterval {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
try{ if (this == o) return true;
DateInterval dateInterval = (DateInterval) obj; if (o == null || getClass() != o.getClass()) return false;
return startTime.equals(dateInterval.getStartTime()) && DateInterval that = (DateInterval) o;
endTime.equals(dateInterval.getEndTime()); return startTime.equals(that.startTime) &&
}catch (Exception e){ endTime.equals(that.endTime);
return false;
}
} }
public Date getStartTime() { public Date getStartTime() {
......
...@@ -119,7 +119,9 @@ public class HadoopUtils implements Closeable { ...@@ -119,7 +119,9 @@ public class HadoopUtils implements Closeable {
fsRelatedProps.forEach((key, value) -> configuration.set(key, value)); fsRelatedProps.forEach((key, value) -> configuration.set(key, value));
}else{ }else{
logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULTFS ); logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULTFS );
throw new RuntimeException("property:{} can not to be empty, please set!"); throw new RuntimeException(
String.format("property: %s can not to be empty, please set!", Constants.FS_DEFAULTFS)
);
} }
}else{ }else{
logger.info("get property:{} -> {}, from core-site.xml hdfs-site.xml ", Constants.FS_DEFAULTFS, defaultFS); logger.info("get property:{} -> {}, from core-site.xml hdfs-site.xml ", Constants.FS_DEFAULTFS, defaultFS);
...@@ -219,10 +221,12 @@ public class HadoopUtils implements Closeable { ...@@ -219,10 +221,12 @@ public class HadoopUtils implements Closeable {
return null; return null;
} }
FSDataInputStream in = fs.open(new Path(hdfsFilePath)); try (FSDataInputStream in = fs.open(new Path(hdfsFilePath))){
BufferedReader br = new BufferedReader(new InputStreamReader(in)); BufferedReader br = new BufferedReader(new InputStreamReader(in));
Stream<String> stream = br.lines().skip(skipLineNums).limit(limit); Stream<String> stream = br.lines().skip(skipLineNums).limit(limit);
return stream.collect(Collectors.toList()); return stream.collect(Collectors.toList());
}
} }
/** /**
......
...@@ -96,7 +96,13 @@ public class DagHelper { ...@@ -96,7 +96,13 @@ public class DagHelper {
for (String startNodeName : startNodeList) { for (String startNodeName : startNodeList) {
TaskNode startNode = findNodeByName(taskNodeList, startNodeName); TaskNode startNode = findNodeByName(taskNodeList, startNodeName);
List<TaskNode> childNodeList = new ArrayList<>(); List<TaskNode> childNodeList = new ArrayList<>();
if (TaskDependType.TASK_POST == taskDependType) { if (startNode == null) {
logger.error("start node name [{}] is not in task node list [{}] ",
startNodeName,
taskNodeList
);
continue;
} else if (TaskDependType.TASK_POST == taskDependType) {
childNodeList = getFlowNodeListPost(startNode, taskNodeList); childNodeList = getFlowNodeListPost(startNode, taskNodeList);
} else if (TaskDependType.TASK_PRE == taskDependType) { } else if (TaskDependType.TASK_PRE == taskDependType) {
childNodeList = getFlowNodeListPre(startNode, recoveryNodeNameList, taskNodeList); childNodeList = getFlowNodeListPre(startNode, recoveryNodeNameList, taskNodeList);
...@@ -129,7 +135,6 @@ public class DagHelper { ...@@ -129,7 +135,6 @@ public class DagHelper {
if (null != depList && null != startNode && depList.contains(startNode.getName())) { if (null != depList && null != startNode && depList.contains(startNode.getName())) {
resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList)); resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
} }
} }
resultList.add(startNode); resultList.add(startNode);
return resultList; return resultList;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册