From b306c6e8d29bac7566e71ef0a37152686828c3a4 Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Thu, 2 Aug 2018 11:35:54 +0900 Subject: NPE and other code smells reported by sonar Issue-ID: VID-278 Change-Id: Ib06ff30a0cc4e9d361a87b791513c8d38a09294a Signed-off-by: Arindam Mondal --- .../src/main/java/org/onap/vid/aai/AaiResponseTranslator.java | 2 +- .../src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java | 2 +- .../AaiGetNetworkCollectionDetailsHelper.java | 2 +- .../src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java | 2 +- vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java | 5 +++-- .../src/main/java/org/onap/vid/services/CsvServiceImpl.java | 5 ++++- 6 files changed, 11 insertions(+), 7 deletions(-) (limited to 'vid-app-common/src/main/java/org') diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java index 6f503799c..c7a98a8cc 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java @@ -61,7 +61,7 @@ public class AaiResponseTranslator { final String errorMessage = aaiResponse.getErrorMessage(); return Optional.of(new PortMirroringConfigDataError( "Got " + aaiResponse.getHttpCode() + " from aai", - errorMessage != null ? errorMessage.toString() : null) + errorMessage != null ? errorMessage : null) ); } else { return Optional.empty(); diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java index d7f9ad879..aab9fc6b3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java @@ -13,7 +13,7 @@ import java.util.List; public class SubscriberListWithFilterData { public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){ - List subscribers = subscriberList != null ? subscriberList.customer : new ArrayList(); + List subscribers = subscriberList != null ? subscriberList.customer : new ArrayList<>(); List subscribersWithFilter = new ArrayList<>(); for (Subscriber subscriber :subscribers){ SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter(); diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java index 2d3cfb918..cb3e548d3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java @@ -14,7 +14,7 @@ public class AaiGetNetworkCollectionDetailsHelper { @JsonProperty("results") private List results = null; @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); @JsonProperty("results") public List getResults() { diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java index cd8cca8f2..fa9fe9350 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java @@ -20,7 +20,7 @@ public class AaiGetPnfResponse { @JsonProperty("results") public List results = null; @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); @JsonAnyGetter public Map getAdditionalProperties() { diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java index 964c7e13e..65fc5217f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java @@ -60,8 +60,9 @@ public class FnAppDoaImpl { if( url!=null && username!=null && password!=null ){ con = DriverManager.getConnection(url, username, password); } - - System.out.println("Connection Successful"); + + logger.info("Connection Successful"); + return con; } 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 6f5f4f732..c34bf4e65 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 @@ -177,7 +177,10 @@ 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); + } + } } } -- cgit 1.2.3-korg