This commit is contained in:
Looly
2019-09-28 03:13:27 +08:00
parent daf85caf9e
commit 596a4f1e57
110 changed files with 535 additions and 617 deletions

View File

@@ -13,14 +13,14 @@ public interface TaskListener {
* 定时任务启动时触发
* @param executor {@link TaskExecutor}
*/
public void onStart(TaskExecutor executor);
void onStart(TaskExecutor executor);
/**
* 任务成功结束时触发
*
* @param executor {@link TaskExecutor}
*/
public void onSucceeded(TaskExecutor executor);
void onSucceeded(TaskExecutor executor);
/**
* 任务启动失败时触发
@@ -28,5 +28,5 @@ public interface TaskListener {
* @param executor {@link TaskExecutor}
* @param exception 异常
*/
public void onFailed(TaskExecutor executor, Throwable exception);
void onFailed(TaskExecutor executor, Throwable exception);
}

View File

@@ -165,7 +165,7 @@ public class CronPattern {
boolean eval;
for (int i = 0; i < matcherSize; i++) {
eval = (isMatchSecond ? secondMatchers.get(i).match(second) : true) // 匹配秒非秒匹配模式下始终返回true
eval = ((false == isMatchSecond) || secondMatchers.get(i).match(second)) // 匹配秒非秒匹配模式下始终返回true
&& minuteMatchers.get(i).match(minute)// 匹配分
&& hourMatchers.get(i).match(hour)// 匹配时
&& isMatchDayOfMonth(dayOfMonthMatchers.get(i), dayOfMonth, month, calendar.isLeapYear(year))// 匹配日
@@ -211,7 +211,7 @@ public class CronPattern {
* @since 4.0.2
*/
private static boolean isMatch(List<ValueMatcher> matchers, int index, int value) {
return (matchers.size() > index) ? matchers.get(index).match(value) : true;
return (matchers.size() <= index) || matchers.get(index).match(value);
}
/**
@@ -253,7 +253,7 @@ public class CronPattern {
}
// 分
try {
this.minuteMatchers.add(ValueMatcherBuilder.build(parts[0 + offset], MINUTE_VALUE_PARSER));
this.minuteMatchers.add(ValueMatcherBuilder.build(parts[offset], MINUTE_VALUE_PARSER));
} catch (Exception e) {
throw new CronException(e, "Invalid pattern [{}], parsing 'minute' field error!", pattern);
}

View File

@@ -19,19 +19,19 @@ public interface ValueParser {
* @param value String值
* @return int
*/
public int parse(String value);
int parse(String value);
/**
* 返回最小值
*
* @return 最小值
*/
public int getMin();
int getMin();
/**
* 返回最大值
*
* @return 最大值
*/
public int getMax();
int getMax();
}

View File

@@ -61,7 +61,7 @@ public class InvokeTask implements Task{
@Override
public void execute() {
try {
ReflectUtil.invoke(this.obj, this.method, new Object[]{});
ReflectUtil.invoke(this.obj, this.method);
} catch (UtilException e) {
throw new CronException(e.getCause());
}

View File

@@ -18,5 +18,5 @@ public interface Task {
* 作业的具体实现需考虑异常情况,默认情况下任务异常在监听中统一监听处理,如果不加入监听,异常会被忽略<br>
* 因此最好自行捕获异常后处理
*/
public void execute();
void execute();
}