cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [1/2] git commit: updated refs/heads/CLOUDSTACK-8560 to 5fe0696
Date Mon, 15 Jun 2015 15:58:58 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/CLOUDSTACK-8560 4b4c52ea7 -> 5fe06962a


Fix 2 findbugs STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE warnings in BaseCmd.java Dateformat
objects are not threadsafe and should be defined as instance variables Both INPUT_FORMAT and
NEW_INPUT_FORMAT are only used in ParamProcessWorker.java and doesn't makes it more readable
to declare in own class

Add missing import statement

Removed extraneous file

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #457


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

Branch: refs/heads/CLOUDSTACK-8560
Commit: ae328a6588b5f8c50f48cb18d904bf1fe35c9493
Parents: 3e3c11f
Author: Rafael da Fonseca <rsafonseca@gmail.com>
Authored: Sun Jun 14 23:00:27 2015 +0200
Committer: Daan Hoogland <daan.hoogland@gmail.com>
Committed: Mon Jun 15 16:32:30 2015 +0200

----------------------------------------------------------------------
 api/src/org/apache/cloudstack/api/BaseCmd.java            | 2 --
 server/src/com/cloud/api/dispatch/ParamProcessWorker.java | 9 ++++++---
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae328a65/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 1226566..ad3a88c 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -87,8 +87,6 @@ public abstract class BaseCmd {
     private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
     public static final String RESPONSE_TYPE_XML = HttpUtils.RESPONSE_TYPE_XML;
     public static final String RESPONSE_TYPE_JSON = HttpUtils.RESPONSE_TYPE_JSON;
-    public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
-    public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     public static final String USER_ERROR_MESSAGE = "Internal error executing command, please
contact your system administrator";
     public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+");
     private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae328a65/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
index b990d4a..eb3b77a 100644
--- a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
+++ b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.regex.Matcher;
+import java.text.SimpleDateFormat;
 
 import javax.inject.Inject;
 
@@ -66,6 +67,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
 public class ParamProcessWorker implements DispatchWorker {
 
     private static final Logger s_logger = Logger.getLogger(ParamProcessWorker.class.getName());
+    public final DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
+    public final DateFormat newInputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     @Inject
     protected AccountManager _accountMgr;
@@ -259,12 +262,12 @@ public class ParamProcessWorker implements DispatchWorker {
                         cmdObj instanceof ArchiveAlertsCmd || cmdObj instanceof DeleteAlertsCmd
|| cmdObj instanceof GetUsageRecordsCmd) {
                     final boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
                     if (isObjInNewDateFormat) {
-                        final DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;
+                        final DateFormat newFormat = newInputFormat;
                         synchronized (newFormat) {
                             field.set(cmdObj, newFormat.parse(paramObj.toString()));
                         }
                     } else {
-                        final DateFormat format = BaseCmd.INPUT_FORMAT;
+                        final DateFormat format = inputFormat;
                         synchronized (format) {
                             Date date = format.parse(paramObj.toString());
                             if (field.getName().equals("startDate")) {
@@ -276,7 +279,7 @@ public class ParamProcessWorker implements DispatchWorker {
                         }
                     }
                 } else {
-                    final DateFormat format = BaseCmd.INPUT_FORMAT;
+                    final DateFormat format = inputFormat;
                     synchronized (format) {
                         format.setLenient(false);
                         field.set(cmdObj, format.parse(paramObj.toString()));


Mime
View raw message