From 84ca0daa195dc3aa7ed6f31a56863ae9f92eac1a Mon Sep 17 00:00:00 2001 From: Chandan Ghosh Date: Mon, 3 Sep 2018 12:36:28 +0530 Subject: 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 --- .../music/lockingservice/ZkStatelessLockService.java | 4 ++-- .../java/org/onap/music/rest/RestMusicAdminAPI.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/main') 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); -- cgit 1.2.3-korg