summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-04-10 12:11:55 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-04-10 12:14:07 -0700
commit19340cad94eeaa1b580f7c0c99531de499e8ca14 (patch)
treeaf4989c384f5d8c54d01b2fa160e2d53ac71a6f5 /adapters/mso-adapter-utils/src
parentd60f3ad34b20c16d31da8f8a09ed2d9adb10f493 (diff)
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 <gary.i.wu@huawei.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java7
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java7
3 files changed, 7 insertions, 13 deletions
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();
}
}