mirror of https://github.com/apache/cloudstack.git
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
This commit is contained in:
parent
3e3c11ffca
commit
ae328a6588
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue