Commit 5e0a8b44c42fc47a843e054b0486e1ed0b34f27a

Authored by 高高
Committed by Gitee
1 parent 97e8c35f

【修复】定时任务指定某一年执行时,只会执行一次,后台查看任务详细会报错

Signed-off-by: 高高 <171376172@qq.com>
yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/util/CronUtils.java
... ... @@ -46,6 +46,10 @@ public class CronUtils {
46 46 List<LocalDateTime> nextTimes = new ArrayList<>(n);
47 47 for (int i = 0; i < n; i++) {
48 48 Date nextTime = cron.getNextValidTimeAfter(now);
  49 + if (nextTime == null) {
  50 + // 如果 nextTime 为 null,说明没有更多的有效时间,退出循环
  51 + break;
  52 + }
49 53 nextTimes.add(LocalDateTimeUtil.of(nextTime));
50 54 // 切换现在,为下一个触发时间;
51 55 now = nextTime;
... ...