Fix for invalid locking approach 27/55427/2
authorvidhyasree <sn141y@att.com>
Tue, 26 Jun 2018 15:55:24 +0000 (11:55 -0400)
committerSantoshi Vidhyasree Nerella <sn141y@att.com>
Tue, 26 Jun 2018 19:04:33 +0000 (19:04 +0000)
Issue-ID: APPC-1019
Change-Id: I738c4ad72c29f494488a3fe3657243927797e2b5
Signed-off-by: vidhyasree <sn141y@att.com>
appc-common/src/main/java/org/onap/appc/encryption/EncryptionTool.java
appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/onap/appc/executor/impl/CommandTask.java
appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java

index 480b15e..37205fc 100644 (file)
@@ -108,13 +108,9 @@ public class EncryptionTool {
      *
      * @return The encryption tool to be used
      */
      *
      * @return The encryption tool to be used
      */
-    public static final EncryptionTool getInstance() {
+    public static final synchronized EncryptionTool getInstance() {
         if (instance == null) {
         if (instance == null) {
-            synchronized (lock) {
-                if (instance == null) {
-                    instance = new EncryptionTool();
-                }
-            }
+            instance = new EncryptionTool();
         }
         return instance;
     }
         }
         return instance;
     }
index 9656644..458814d 100644 (file)
@@ -48,8 +48,6 @@ import java.net.InetAddress;
 import java.util.UUID;
 
 import static com.att.eelf.configuration.Configuration.*;
 import java.util.UUID;
 
 import static com.att.eelf.configuration.Configuration.*;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
 
 /**
  * This abstract class is base class for all Command tasks. All command task must inherit this class.
 
 /**
  * This abstract class is base class for all Command tasks. All command task must inherit this class.
index 9d6c888..aa6d203 100644 (file)
@@ -74,7 +74,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
-
+import java.util.TimeZone;
 import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
 import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
 import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
 import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
 import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
 import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
@@ -226,11 +226,11 @@ public abstract class AbstractRequestHandlerImpl implements RequestHandler {
         }
         updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.STATE, record.getRequestState());
         updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.RESULT_CODE,
         }
         updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.STATE, record.getRequestState());
         updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.RESULT_CODE,
-            String.valueOf(record.getResultCode()));
+                String.valueOf(record.getResultCode()));
         if (RequestStatus.valueOf(record.getRequestState()).isTerminal()) {
         if (RequestStatus.valueOf(record.getRequestState()).isTerminal()) {
-            Date endTime = new Date(System.currentTimeMillis());
+            Date endTime = new Date();
             updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.END_TIME,
             updateColumns.put(TransactionConstants.TRANSACTION_ATTRIBUTES.END_TIME,
-                dateToStringConverterMillis(endTime));
+                    dateToStringConverterMillis(endTime));
         }
         try {
             transactionRecorder.update(record.getTransactionId(), updateColumns);
         }
         try {
             transactionRecorder.update(record.getTransactionId(), updateColumns);
@@ -461,6 +461,7 @@ public abstract class AbstractRequestHandlerImpl implements RequestHandler {
 
     public static String dateToStringConverterMillis(Date date) {
         SimpleDateFormat customDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 
     public static String dateToStringConverterMillis(Date date) {
         SimpleDateFormat customDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+        customDate.setTimeZone(TimeZone.getTimeZone("UTC"));
         if (date != null) {
             return customDate.format(date);
         }
         if (date != null) {
             return customDate.format(date);
         }