Skip to content

Commit

Permalink
Merge pull request #3605 from wankaiyi/master
Browse files Browse the repository at this point in the history
限制子任务不能是任务本身,防止递归调用和死循环
  • Loading branch information
xuxueli authored Jan 11, 2025
2 parents 5f0e0cd + 2bd5127 commit 76e49cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ private static void finishJob(XxlJobLog xxlJobLog){
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
for (int i = 0; i < childJobIds.length; i++) {
int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
if (childJobId == xxlJobLog.getJobId()) {
logger.info("jobid {} is self, ignore it.", childJobId);
continue;
}
if (childJobId > 0) {

JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ public ReturnT<String> update(XxlJobInfo jobInfo, XxlJobUser loginUser) {
String[] childJobIds = jobInfo.getChildJobId().split(",");
for (String childJobIdItem: childJobIds) {
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
int childJobId = Integer.parseInt(childJobIdItem);
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(childJobId);
if (childJobId == jobInfo.getId()) {
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_childJobId")+"("+childJobId+")"+I18nUtil.getString("system_unvalid")) );
}
if (childJobInfo==null) {
return new ReturnT<String>(ReturnT.FAIL_CODE,
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
Expand Down

0 comments on commit 76e49cb

Please sign in to comment.