Fix for invalid day of week max check (#1986)

Closes #1813

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
Hilbrand Bouwkamp 2020-12-22 20:42:37 +01:00 committed by GitHub
parent 7ce96ac06a
commit df2013805b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -280,11 +280,6 @@ class CronAdjuster implements SchedulerTemporalAdjuster {
final String[] increments = sub.split("/");
final int[] range = parseRange(cronExpression, chronoField, increments[0], min, max, names);
if (chronoField == ChronoField.DAY_OF_WEEK) {
range[0] = range[0] - 1;
range[1] = range[1] - 1;
}
if (increments.length == 2) {
// we had a / expression
final int increment = parseInt(cronExpression, chronoField, increments[1]);
@ -488,7 +483,7 @@ class CronAdjuster implements SchedulerTemporalAdjuster {
if (nameIndex == null) {
return parseInt(cronExpression, chronoField, name);
} else {
return min + nameIndex;
return min + nameIndex - (chronoField == ChronoField.DAY_OF_WEEK ? 1 : 0);
}
}

View File

@ -145,6 +145,8 @@ public class CronAdjusterTest {
{ JAN_1ST_2015, "0 0 0 ? * SUN", new String[] { "2015-01-04T00:00" } },
{ JAN_1ST_2015, "0 0 0 ? * SUN-MON",
new String[] { "2015-01-04T00:00", "2015-01-05T00:00", "2015-01-11T00:00" } },
{ JAN_1ST_2015, "0 0 0 ? * MON-SUN",
new String[] { "2015-01-02T00:00", "2015-01-03T00:00", "2015-01-04T00:00" } },
{ JAN_1ST_2000, "14-02/2 * * * * *",
new String[] { "2000-01-01T00:00:02", "2000-01-01T00:00:14", "2000-01-01T00:00:16",
"2000-01-01T00:00:18" } },