Fix Sonar issues within SliPluginUtils module
authorArun S. Yerra <arun.yerra@huawei.com>
Thu, 7 Sep 2017 18:09:06 +0000 (11:09 -0700)
committerArun S. Yerra <arun.yerra@huawei.com>
Fri, 8 Sep 2017 05:28:38 +0000 (22:28 -0700)
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 <arun.yerra@huawei.com>
sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java

index e6811e7..488dc39 100644 (file)
@@ -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;
+               }
        }
 
        /**