From 19340cad94eeaa1b580f7c0c99531de499e8ca14 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Mon, 10 Apr 2017 12:11:55 -0700 Subject: Remove unnecessary use of Calendar.getInstance() Calendar.getInstance() is expensive and unnecessary when we only need the system time. This change replaces the uses of Calendar.getInstance() with System.currentTimeMillis(). Change-Id: I476f8850f5eb88d20cf7249cca5bb2e9b671b45a Signed-off-by: Gary Wu --- .../main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java | 7 +------ .../java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java | 6 +++++- .../java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java | 7 +------ 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index 8d66505c6a..9309f05c40 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -1096,12 +1096,7 @@ public class MsoHeatUtils extends MsoCommonUtils { return true; } - Calendar now = Calendar.getInstance (); - if (now.after (expires)) { - return true; - } - - return false; + return System.currentTimeMillis() > expires.getTimeInMillis(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java index 82203d044c..8375b973c9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java @@ -658,7 +658,11 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } public boolean isExpired () { - return Calendar.getInstance ().after (expires); + if (expires == null) { + return true; + } + + return System.currentTimeMillis() > expires.getTimeInMillis(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java index 7e388a5ef8..f3281e3f1c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java @@ -585,12 +585,7 @@ public class MsoNeutronUtils extends MsoCommonUtils return true; } - Calendar now = Calendar.getInstance(); - if (now.after(expires)) { - return true; - } - - return false; + return System.currentTimeMillis() > expires.getTimeInMillis(); } } -- cgit 1.2.3-korg