lowered some code smells 17/106717/3
authorIndrijeet kumar <indriku1@in.ibm.com>
Tue, 28 Apr 2020 02:57:20 +0000 (08:27 +0530)
committerIndrijeet Kumar <indriku1@in.ibm.com>
Thu, 28 May 2020 04:12:37 +0000 (04:12 +0000)
lowered some code smells

Issue-ID: PORTAL-869
Change-Id: I38a7c71f67b05bea076c6a0912712097da2093c7
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
music-core/src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java
music-core/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java
music-core/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
music-core/src/main/java/org/onap/music/main/CipherUtil.java

index cd767a4..29fdb1d 100644 (file)
@@ -190,7 +190,6 @@ public class JsonUpdate implements Serializable {
          }
          
          EELFLoggerDelegate.mdcPut("keyspace", "( "+this.getKeyspaceName()+" ) ");
-         long startTime = System.currentTimeMillis();
          String operationId = UUID.randomUUID().toString();  // just for infoging purposes.
          String consistency = this.getConsistencyInfo().get("type");
 
@@ -311,9 +310,6 @@ public class JsonUpdate implements Serializable {
             conditionInfo = new Condition(this.getConditions(), selectQuery);
         }
 
-        ReturnType operationResult = null;
-        long jsonParseCompletionTime = System.currentTimeMillis();
-
         if(consistency.equalsIgnoreCase(MusicUtil.EVENTUAL) && this.getConsistencyInfo().get("consistency") != null) {
             if(MusicUtil.isValidConsistency(this.getConsistencyInfo().get("consistency"))) {
                 queryObject.setConsistency(this.getConsistencyInfo().get("consistency"));
@@ -376,7 +372,7 @@ public class JsonUpdate implements Serializable {
         }
 
         public String getRowIdString() {
-            return this.rowIdString.toString();
+            return this.rowIdString;
         }
 
         public void setRowIdString(String rowIdString) {
index 0c5d39c..9a69a9b 100644 (file)
@@ -503,7 +503,7 @@ public class CassaLockStore {
     }
     
     public List<String> getAllLocksForOwner(String ownerId, String keyspace, String table) throws MusicServiceException, MusicQueryException {
-        List<String> toRet = new ArrayList<String>();
+        List<String> toRet = new ArrayList<>();
         String lockTable = table_prepend_name + table;
         PreparedQueryObject queryObject = new PreparedQueryObject();
         queryObject.appendQueryString("SELECT key, lockreference FROM " + keyspace + "." + lockTable);
index 492a48f..1f40f2b 100644 (file)
 package org.onap.music.lockingservice.cassandra;
 
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 import org.onap.music.datastore.MusicDataStoreHandle;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
 import org.onap.music.main.MusicCore;
 import org.onap.music.main.MusicUtil;
index 00187dc..14fb813 100644 (file)
@@ -39,15 +39,18 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
 
 // the state variable that will be stored in the locking service, capturing the transitions of
 public class MusicLockState implements Serializable {
+    // captures the state of the lock
     public enum LockStatus {
         UNLOCKED, BEING_LOCKED, LOCKED
-    };// captures the state of the lock
+    }
+  
 
     private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicLockState.class);
     private LockStatus lockStatus;
     private boolean needToSyncQuorum = false;
     private String lockHolder;
-    private long leasePeriod = Long.MAX_VALUE, leaseStartTime = -1;
+    private long leasePeriod = Long.MAX_VALUE;
+    private long leaseStartTime = -1;
     private String errorMessage = null;
     
     public MusicLockState(String errorMessage) {
index 3278dc1..9a8ff69 100644 (file)
@@ -168,7 +168,8 @@ public class CipherUtil {
      */
     public static String encryptPKC(String value, String skey)  {
         Cipher cipher = null;
-        byte[] iv = null, finalByte = null;
+        byte[] iv = null;
+        byte[] finalByte = null;
 
         try {
             cipher = Cipher.getInstance(ALGORYTHM_DETAILS, "SunJCE");