From aa5441ed5a583c3b0c9e487108cd691310c1e78a Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Thu, 7 Sep 2017 11:09:06 -0700 Subject: Fix Sonar issues within SliPluginUtils module Sonarqube report for SliPluginUtils identified some critical bugs. This fix will address these bugs. Issue-Id: CCSDK-81 Change-Id: I9a1738c02f1364b17a0895b94f26c373e4a19f1f Signed-off-by: Arun S. Yerra --- .../sli/core/slipluginutils/SliPluginUtils.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sliPluginUtils/provider') diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index e6811e78..488dc395 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -489,6 +490,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { switch( logLevel ) { case TRACE: log.trace(log_message); + break; case DEBUG: log.debug(log_message); break; @@ -648,6 +650,38 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { return 0; } + + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof SortableCtxListElement)) { + return false; + } + if (!super.equals(object)) { + return false; + } + + SortableCtxListElement that = (SortableCtxListElement) object; + + if (child_elements != null ? !child_elements.equals(that.child_elements) + : that.child_elements != null) { + return false; + } + // Probably incorrect - comparing Object[] arrays with Arrays.equals + if (!Arrays.equals(sort_fields, that.sort_fields)) { + return false; + } + + return true; + } + + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (child_elements != null ? child_elements.hashCode() : 0); + result = 31 * result + Arrays.hashCode(sort_fields); + return result; + } } /** -- cgit 1.2.3-korg