mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
fix: NPE when user use invalid params #87
This commit is contained in:
parent
5cf43ddb2a
commit
d8062f810c
@ -78,9 +78,8 @@ public class JobService {
|
|||||||
jobInfoDO.setTimeExpressionType(request.getTimeExpressionType().getV());
|
jobInfoDO.setTimeExpressionType(request.getTimeExpressionType().getV());
|
||||||
jobInfoDO.setStatus(request.isEnable() ? SwitchableStatus.ENABLE.getV() : SwitchableStatus.DISABLE.getV());
|
jobInfoDO.setStatus(request.isEnable() ? SwitchableStatus.ENABLE.getV() : SwitchableStatus.DISABLE.getV());
|
||||||
|
|
||||||
if (jobInfoDO.getMaxWorkerCount() == null) {
|
// 填充默认值,非空保护防止 NPE
|
||||||
jobInfoDO.setMaxWorkerCount(0);
|
fillDefaultValue(jobInfoDO);
|
||||||
}
|
|
||||||
|
|
||||||
// 转化报警用户列表
|
// 转化报警用户列表
|
||||||
if (!CollectionUtils.isEmpty(request.getNotifyUserIds())) {
|
if (!CollectionUtils.isEmpty(request.getNotifyUserIds())) {
|
||||||
@ -230,4 +229,13 @@ public class JobService {
|
|||||||
jobInfoDO.setGmtModified(now);
|
jobInfoDO.setGmtModified(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fillDefaultValue(JobInfoDO jobInfoDO) {
|
||||||
|
if (jobInfoDO.getMaxWorkerCount() == null) {
|
||||||
|
jobInfoDO.setMaxWorkerCount(0);
|
||||||
|
}
|
||||||
|
if (jobInfoDO.getMaxInstanceNum() == null) {
|
||||||
|
jobInfoDO.setMaxInstanceNum(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user