fix: NPE when user use invalid params #87

This commit is contained in:
“tjq” 2020-11-07 22:09:38 +08:00
parent 5cf43ddb2a
commit d8062f810c

View File

@ -78,9 +78,8 @@ public class JobService {
jobInfoDO.setTimeExpressionType(request.getTimeExpressionType().getV());
jobInfoDO.setStatus(request.isEnable() ? SwitchableStatus.ENABLE.getV() : SwitchableStatus.DISABLE.getV());
if (jobInfoDO.getMaxWorkerCount() == null) {
jobInfoDO.setMaxWorkerCount(0);
}
// 填充默认值非空保护防止 NPE
fillDefaultValue(jobInfoDO);
// 转化报警用户列表
if (!CollectionUtils.isEmpty(request.getNotifyUserIds())) {
@ -230,4 +229,13 @@ public class JobService {
jobInfoDO.setGmtModified(now);
}
private void fillDefaultValue(JobInfoDO jobInfoDO) {
if (jobInfoDO.getMaxWorkerCount() == null) {
jobInfoDO.setMaxWorkerCount(0);
}
if (jobInfoDO.getMaxInstanceNum() == null) {
jobInfoDO.setMaxInstanceNum(0);
}
}
}