You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/10/19 02:37:01 UTC

git commit: updated refs/heads/master to 9d62540

Updated Branches:
  refs/heads/master ebd4b8fa9 -> 9d625405d


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


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9d625405
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9d625405
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9d625405

Branch: refs/heads/master
Commit: 9d625405d3c322c76c6935fd7a5ab1b576d64e16
Parents: ebd4b8f
Author: Prachi Damle <pr...@citrix.com>
Authored: Fri Oct 18 16:16:28 2013 -0700
Committer: Prachi Damle <pr...@cloud.com>
Committed: Fri Oct 18 17:25:14 2013 -0700

----------------------------------------------------------------------
 utils/src/com/cloud/utils/DateUtil.java | 41 ++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d625405/utils/src/com/cloud/utils/DateUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/DateUtil.java b/utils/src/com/cloud/utils/DateUtil.java
index 1854e15..1ddb65d 100644
--- a/utils/src/com/cloud/utils/DateUtil.java
+++ b/utils/src/com/cloud/utils/DateUtil.java
@@ -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