-
Bug
-
Resolution: Unresolved
-
Medium
-
Kohn Release
-
None
From Fix bug in wrong SNSSAI value being appended with MeasType string (Iac3e66e8) · Gerrit Code Review (onap.org):
components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java
Line 122
You are scanning the end of the string twice (contains() and lastIndexOf(), This can be changed to: int dotLocation = anyString.lastIndexOf("."); if (dotLocation != -1) {
value = anyString.substring(dotLocation + 1);
components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java
Line 110
There is still a bug here if operand is not assigned a value within the above loop. Probably the easiest fix is to change the operand initialization above to: String operand = ""; Alternatively, test for null explicitly. See the next comment for an alternative that fixes this and another issue.
Line 114
this log message is not the opposite of the test. I suggest changing the order of tests to: if (operand == null || operand.isEmpty())
else if (operand.contains(".")) { snssai = operand.substring(operand.lastIndexOf(".") + 1); }
Note that if this is in a tight loop and becomes time-critical, this has the issue that operand is scanning the end of the string twice for ".". So another formulation would be: if (operand == null || operand.isEmpty())
else { int dotLocation = operand.lastIndexOf("."); if (dotLocation != -1)
{ snssai = operand.substring(dotLocation + 1); }}