diff options
author | Parshad Patel <pars.patel@samsung.com> | 2019-04-22 13:09:58 +0900 |
---|---|---|
committer | Parshad Patel <pars.patel@samsung.com> | 2019-04-22 13:23:52 +0900 |
commit | 73e90ce42013fbd2ee87477a2cd8c72eb234df3d (patch) | |
tree | bf3a8dd08f34972500f401049481f6dd73ae61e8 /vid-app-common/src/main/java/org/onap | |
parent | f2dc71a2443c29c00da7750230015d6555e86b1f (diff) |
Fix sonar issues in vid
Fix A "NullPointerException" could be thrown issue
Fix Either log or rethrow this exception issue
Issue-ID: VID-464
Change-Id: I92fc200bf019fc335dde8a27b50e36cefffda440
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
4 files changed, 10 insertions, 7 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index 6a8439fee..1710d984f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -195,6 +195,7 @@ public class AaiClient implements AaiClientInterface { return new AaiResponse(e.getCause(), "AAI response parsing Error" , HttpStatus.SC_INTERNAL_SERVER_ERROR); } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger,"Exception in aai response parsing", e); return new AaiResponse(e.getCause(), "Got " + aaiResponse.getHttpCode() + " from a&ai" , aaiResponse.getHttpCode()); } } @@ -335,8 +336,8 @@ public class AaiClient implements AaiClientInterface { encodedParam= URLEncoder.encode(param, "UTF-8"); } catch (UnsupportedEncodingException e) { String methodName = "getUrlFromList"; - logger.error(EELFLoggerDelegate.errorLogger, methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, methodName, e); + logger.debug(EELFLoggerDelegate.debugLogger, methodName, e); } url = url.concat(encodedParam); if(i != params.size()){ diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java index 1ee4da0b4..5641bc502 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java @@ -51,8 +51,8 @@ public class PombaClientImpl implements PombaClientInterface { try { pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request)); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, methodName, e); + logger.debug(EELFLoggerDelegate.debugLogger, methodName, e); } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java index 129a61041..b118901a4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java @@ -50,8 +50,8 @@ public class PombaRestInterface extends AAIRestInterface { client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient", e); + logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : ", e); } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java index 4a5564e9c..4aabdae21 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java @@ -197,7 +197,9 @@ public class CsvServiceImpl implements CsvService{ currentJson.put(new JSONObject().put(key, values)); } else { JSONObject lastItem = lastItemInArray(currentJson); - lastItem.put(key, values); + if(lastItem != null) { + lastItem.put(key, values); + } } } } |