From: Chandan Ghosh Date: Mon, 3 Sep 2018 07:06:28 +0000 (+0530) Subject: Added fix for potential nullpointerexception X-Git-Tag: 3.0.23~28^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=84ca0daa195dc3aa7ed6f31a56863ae9f92eac1a;p=music.git Added fix for potential nullpointerexception Added fix for potential nullpointerexception and added error log reported in sonarqube Issue-ID: MUSIC-119 Change-Id: I13b3b13b1caa209c0f9ff9f19b38a62c4486c2fe Signed-off-by: Chandan Ghosh --- diff --git a/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java b/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java index 5f9c07ee..b09668b7 100644 --- a/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java +++ b/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java @@ -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; } diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java index 48f28f8c..937ec77a 100755 --- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java @@ -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);