Added fix for potential nullpointerexception 71/64171/3
authorChandan Ghosh <cghosh12@in.ibm.com>
Mon, 3 Sep 2018 07:06:28 +0000 (12:36 +0530)
committerChandan Ghosh <cghosh12@in.ibm.com>
Mon, 3 Sep 2018 07:41:39 +0000 (13:11 +0530)
Added fix for potential nullpointerexception and added error log reported in sonarqube

Issue-ID: MUSIC-119
Change-Id: I13b3b13b1caa209c0f9ff9f19b38a62c4486c2fe
Signed-off-by: Chandan Ghosh <cghosh12@in.ibm.com>
src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java
src/main/java/org/onap/music/rest/RestMusicAdminAPI.java

index 5f9c07e..b09668b 100644 (file)
@@ -298,7 +298,7 @@ public class ZkStatelessLockService extends ProtocolSupport {
                         try {
                             stat = zookeeper.exists(id, false);
                         } catch (KeeperException | InterruptedException e1) {
-                            e1.printStackTrace();
+                            logger.error(EELFLoggerDelegate.errorLogger, "Error in execute: " + e1);
                         }
                         Long ctime = stat.getCtime();
                         MusicUtil.zkNodeMap.put(id, ctime);
@@ -310,7 +310,7 @@ public class ZkStatelessLockService extends ProtocolSupport {
                             pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), ctime));
                             MusicCore.eventualPut(pQuery);
                         } catch (Exception e) {
-                               e.printStackTrace();
+                               logger.error(EELFLoggerDelegate.errorLogger, "Error in execute: " + e);
                         }
                         break;
                    }
index 48f28f8..937ec77 100755 (executable)
@@ -506,19 +506,24 @@ public class RestMusicAdminAPI {
                        logger.info(operation+ ": Operation :: changeValue: "+changeValueMap);
                        if(operation.equals("update")) {
                                String notifyWhenChangeIn = baseRequestObj.getNotifyWhenChangeIn(); // conductor.plans.status
-                               if(field_value.equals(notifyWhenChangeIn)) {
-                                       notifyCallBackAppl(jsonResponse, baseRequestObj);
+                               if(null!=field_value) {
+                                       if(field_value.equals(notifyWhenChangeIn)) {
+                                               notifyCallBackAppl(jsonResponse, baseRequestObj);
+                                       }
                                }
-                               
                        } else if(operation.equals("delete")) {
                                String notifyWhenDeletesIn = baseRequestObj.getNotifyWhenDeletesIn(); // conductor.plans.status
-                               if(field_value.equals(notifyWhenDeletesIn)) {
-                                       notifyCallBackAppl(jsonResponse, baseRequestObj);
+                               if(null!=field_value) {
+                                       if(field_value.equals(notifyWhenDeletesIn)) {
+                                               notifyCallBackAppl(jsonResponse, baseRequestObj);
+                                       }
                                }
                        } else if(operation.equals("insert")) {
                                String notifyWhenInsertsIn = baseRequestObj.getNotifyWhenInsertsIn(); // conductor.plans.status
-                               if(field_value.equals(notifyWhenInsertsIn)) {
-                                       notifyCallBackAppl(jsonResponse, baseRequestObj);
+                               if(null!=field_value) {
+                                       if(field_value.equals(notifyWhenInsertsIn)) {
+                                               notifyCallBackAppl(jsonResponse, baseRequestObj);
+                                       }
                                }
                        }
                        MusicCore.releaseLock(lockId, true);