MusicCore.java : Fixed sonar issue 97/63197/1
authorArundathi Patil <arundpil@in.ibm.com>
Tue, 28 Aug 2018 07:16:42 +0000 (12:46 +0530)
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>
Tue, 28 Aug 2018 07:16:52 +0000 (12:46 +0530)
Fixed sonar issue, null pointer exception could be thrown

Issue-ID: MUSIC-111
Change-Id: I4ea473a5e656292ecfd807ab84793f7c4ec233b2
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
src/main/java/org/onap/music/main/MusicCore.java

index b729ba7..aaaeae3 100644 (file)
@@ -73,7 +73,10 @@ public class MusicCore {
         public boolean testCondition() throws Exception {
             // first generate the row
             ResultSet results = quorumGet(selectQueryForTheRow);
-            Row row = results.one();
+            Row row = null;
+            if(results != null) {
+                row = results.one();
+            }
             return getDSHandle().doesRowSatisfyCondition(row, conditions);
         }
     }
@@ -288,7 +291,8 @@ public class MusicCore {
         MusicLockState newMls = null;
         try {
             currentMls = getMusicLockState(key);
-            String currentLockHolder = currentMls.getLockHolder();
+            String currentLockHolder = null;
+            if(currentMls != null) { currentLockHolder = currentMls.getLockHolder(); };
             if (lockId.equals(currentLockHolder)) {
                 logger.info(EELFLoggerDelegate.applicationLogger,"In acquire lock: You already have the lock!");
                 return new ReturnType(ResultType.SUCCESS, "You already have the lock!");