mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
This adds a test from HUDSON-8656, and is likely related to issues found in
HUDSON-8401. This grouping of tests targets all Sunday to *another day of week* cron tabs. There are likely other pairs that could be tested, but this seemed to work out most of the bugs.
This commit is contained in:
1 parent
8e432f8f71
commit
e7eac75978
2 files changed
+294
-2
No files matched your search
@@ -218,18 +218,23 @@ public final class CronTab {
|
||||
private static final CalendarField DAY_OF_WEEK = new CalendarField("dow", Calendar.DAY_OF_WEEK, 1,-1, true, HOUR) {
|
||||
long bits(CronTab c) { return c.dayOfWeek; }
|
||||
void rollUp(Calendar cal, int i) {
|
||||
cal.add(Calendar.DAY_OF_WEEK,7);
|
||||
cal.add(Calendar.DAY_OF_WEEK, 7 * i);
|
||||
}
|
||||
|
||||
@Override
|
||||
void setTo(Calendar c, int i) {
|
||||
int v = i-offset;
|
||||
int was = c.get(field);
|
||||
c.set(field,v);
|
||||
if (v<c.getFirstDayOfWeek()) {
|
||||
final int firstDayOfWeek = c.getFirstDayOfWeek();
|
||||
if (v < firstDayOfWeek && was >= firstDayOfWeek) {
|
||||
// in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days.
|
||||
// When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes
|
||||
// the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here.
|
||||
addTo(c,-7);
|
||||
} else if (was < firstDayOfWeek && firstDayOfWeek <= v) {
|
||||
// If we wrap the other way around, we need to adjust in the opposite direction of above.
|
||||
addTo(c, 7);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user