mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-4895: Management server fails to start because snapshot policy time zones have day light savings
Changes: - Calendar throws IllegalArgumentException when the hour of the day happens to be skipped due to DST changes. - Fix will ask Calendar to adjust the time accordingly and get the next closest time
This commit is contained in:
parent
ebd4b8fa9f
commit
9d625405d3
@ -148,7 +148,13 @@ public class DateUtil {
|
||||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
@ -168,7 +174,13 @@ public class DateUtil {
|
||||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
@ -189,7 +201,13 @@ public class DateUtil {
|
||||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
@ -213,7 +231,13 @@ public class DateUtil {
|
||||
scheduleTime.set(Calendar.MINUTE, minutes);
|
||||
scheduleTime.set(Calendar.SECOND, 0);
|
||||
scheduleTime.set(Calendar.MILLISECOND, 0);
|
||||
execDate = scheduleTime.getTime();
|
||||
try {
|
||||
execDate = scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
execDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
}
|
||||
// XXX: !execDate.after(startDate) is strictly for testing.
|
||||
// During testing we use a test clock which runs much faster than the real clock
|
||||
// So startDate and execDate will always be ahead in the future
|
||||
@ -226,7 +250,14 @@ public class DateUtil {
|
||||
throw new CloudRuntimeException("Incorrect interval: "+type.toString());
|
||||
}
|
||||
|
||||
return scheduleTime.getTime();
|
||||
try {
|
||||
return scheduleTime.getTime();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
scheduleTime.setLenient(true);
|
||||
Date nextScheduledDate = scheduleTime.getTime();
|
||||
scheduleTime.setLenient(false);
|
||||
return nextScheduledDate;
|
||||
}
|
||||
}
|
||||
|
||||
// test only
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user